I believe you want to change sub_c so that it just looks like:
Here's the whole script cleaned up a little:sub sub_c { my %hash1c = @_; print "sub_c arguments: " . Dumper \%hash1c; }
[05:25][nick:~/monks]$ cat 1134864.pl #! perl use strict; use warnings; use feature qw/ say /; use Data::Dumper; sub sub_b { my %hash1b; $hash1b{'key1'} = 1; say 'calling sub_c from sub_b'; sub_c( %hash1b ); } sub sub_c { my %hash1c = @_; say 'sub_c arguments: ' . Dumper \%hash1c; } say 'calling sub_b'; sub_b(); my %hash1a; $hash1a{'key1'} = 1; say 'calling sub_c directly'; sub_c( %hash1a ); __END__
[05:25][nick:~/monks]$ perl 1134864.pl calling sub_b calling sub_c from sub_b sub_c arguments: $VAR1 = { 'key1' => 1 }; calling sub_c directly sub_c arguments: $VAR1 = { 'key1' => 1 };
In reply to Re: Passing by reference from within a sub
by 1nickt
in thread Passing by reference from within a sub
by arvid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |