Passing an array like in sub(%prevsidstat) flattens the hash into a list and passes the list.
This would be better, passing the references
my $loopCnt=0; my $prevsidstat=getSessStat(); while (1) { debug("Sleeping for $ENV{SESSNAP_INTRVL}...\n"); sleep $ENV{SESSNAP_INTRVL}; my $cursidstat=getSessStat(); if ((keys %$cursidstat) != 0 ) { my $ComResult={sidStatComp($prevsidstat,$cursidstat)}; $prevsidstat=$cursidstat; } last; } sub sidStatComp { #***************************************************** my ($prevsidstat,$cursidstat)=@_; print "Previous\n"; for my $instsid (keys %$prevsidstat) { print "$instsid =>".$prevsidstat->{$instsid}{SQLEXECINFO}."\n"; } print "Current\n"; for my $instsid1 (keys %$cursidstat) { print "$instsid1 =>". $cursidstat->{$instsid1}{SQLEXECINFO}."\n"; } return 1; }
In reply to Re: Passing hashes to sub
by huck
in thread Passing hashes to sub
by PSP
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |