So you'll either want to put the scalar value first and shift it off:# functionally speaking, this.... %hash = ('a' => 1, 'b' => 2, 'c' => 3); myfunc(%hash); # is the same as this... myfunc('a', 1, 'b', 2, 'c', 3);
Or pass arrays and hashes by reference, because when you pass a reference to an array or hash, the reference is a scalar context.$scalar = 'blue'; %hash = ('a' => 1, 'b' => 2); myfunc($scalar, %hash); sub myfunc { my $scalar = shift; my %hash = @_; print $hash{'a'}; }
%hash = ('a' => 1, 'b' => 2); $scalar = 'blue'; myfunc(\%hash, $scalar); sub myfunc { my($hashref,$scalar) = @_; print $hashref->{'a'}; }
__________
Systems development is like banging your head against a wall...
It's usually very painful, but if you're persistent, you'll get through it.
In reply to Re^3: Transferring local hashes to module subroutines
by EvanK
in thread Transferring local hashes to module subroutines
by cowgirl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |