sub func2 {
my ($ref_hash) = @_;
foreach my $key ( keys %$ref_hash ){
print "$key: $ref_hash->{$key}\n";
}
}
What you can't do here is:
sub func2 {
my %hash = @_;
....
}
You've broken the reference back to the original hash.
you will modify the elements in %hash, but not in your %tariffData
But you can declare a reference
my %tarrifData;
func1(\%tarrifData);
# %tarrifData has been changed
func2(\%tarrifData);
func3(\%tarrifData); # does not modify %tarrifData
sub func1 {
my $ref = shift; # points to %tarrifData
# Do Something
}
sub func2 {
my $ref = shift; # points again to %tarrifData
# Do something else
}
sub func3 {
my %hash = %{$_[0]}; # no longer points to %tarrifData
undef %hash; # who cares?
}
now go read the perldocs.. :)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>