Or, if you don't want to use hashrefs, you can domy %argHash = ( abcd => 'efgh', ijkl => 'mnop', ); &first(\%argHash); sub first { my $args = shift; print "$_ => $args->{$_}\n" foreach sort keys %$args; &second({%$args, qrst => 'uvwx'}); } sub second { my $args = shift; print "$_ => $args->{$_}\n" foreach sort keys %$args; }
Note how the two use different braces at different times. Either is just fine. The second is prone to more errors in coercing the array @_ into the hash %args, but, so long as you know exactly what's going into that hash, you should be fine. Try them out and see which you prefer.my %argHash = ( abcd => 'efgh', ijkl => 'mnop', ); &first(\%argHash); sub first { my %args = @_; print "$_ => $args->{$_}\n" foreach sort keys %args; &second(%$args, qrst => 'uvwx'); } sub second { my %args = @_; print "$_ => $args{$_}\n" foreach sort keys %args; }
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
In reply to Re5: Understanding why strict prevents a use of local
by dragonchild
in thread Understanding why strict prevents a use of local
by c
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |