Here you are.
The example should explain you quite clearly how to solve your prob.
cheers!
#!usr/bin/perl
sub meteathash()
{
#the parameter is passed by reference via the \
my $varhashref= shift;
#we need to CAST the reference as a hash
#Same method would be used for arrays too
%varlocalhash= %$varhashref;
foreach $varkey (keys (%varlocalhash))
{
print STDERR "\nKey local: $varkey Value: " . $varlocalhash{$v
+arkey};
}
}
@varkeyz= ('a','b','c','d');
@varkeyztwo= ('aa','bb','cc','dd');
@varvaluez=(1,2,3,4);
=comment
print STDERR "\nkeyz: @varkeyz";
print STDERR "\nvalz: @varvaluez";
=cut
@varhash{@varkeyz}= @varvaluez;
@varhashtwo{@varkeyztwo}= @varvaluez;
=comment
foreach $varkey (keys (%varhash))
{
print STDERR "\nKey: $varkey Value: " . $varhash{$varkey};
}
=cut
&meteathash(\%varhash);
print STDERR "\nherecomesthesecondhash";
&meteathash(\%varhashtwo);
|