On Jan 19, 2004, at 5:26 AM, Tushar Gokhale wrote:

I have a hash table which contains values like
my %enumerations = (
#mystat mode
'edcf' => '1',
'hcf' => '2',
#admin state
'disable' => '0',
'enable' => '1',
);
I have created a library of common functions and the above mentioned hash
table is present in my each script, each script is calling the
library,where it is using the hash table values. For some test cases
application is returning disable value as 3, and hcf has a value 4.


Any one solution can solve my problem

1. How do i pass hash table to function?

I suspect you may be looking for references here, though I'm not sure I understand the problem completely. Here's how you might use references to pass the above hash around:


do_something( \%enumerations }; # pass hash by reference

sub do_something {                                      # example routine
        my $enums = shift;                              # fetch reference
        print $enums->{enable}, "\n";              # use hash
        $enums->{enable} = 42;                       # alter hash
        print $enums->{enable}, "\n";              # see results
}

print "$enumerations{enable}\n"; # show original hash is altered

2. Once the hash table is set my program refers to this table and i want to
change the hash table values with each executing script which is not
happening, its still refering to the old hash table values and my test is
failing. So how do I reset values in hash table?

I'm not sure I understand this question at all. Is the hash being written to a file and read back in? Please, give some more details and I will try to help.


James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to