in reply to Re^4: referances of hashes, and subroutines
in thread referances of hashes, and subroutines
In this case, since passing a hash reference, my suffix is 'hr'. If it was an array reference, I'd tack on '_ar'. The suffix does nothing to guarantee that what's in that scalar variable is really an array reference or a hash reference, but it sure makes reading over the code later easier when you are trying to remember what each variable is supposed to be doing and how it is built.use strict; my %hash = qw( abc xyz ); print "Hash key(s) are:\n"; print "$_\n" foreach my_sub( \%hash ); sub my_sub { my ( $hash_hr ) = @_; return ( keys %$hash_hr ); }
By the way, even though only one argument is being passed, I like my subroutines to receive them from @_ via list context since it makes it easier to grow/evolve the subroutine later on. Same for passing return values....
|
|---|