It's a whole lot easier and more subtle than you might expect. Perl actually passes parameters as aliases in @_ so we can:
use warnings; use strict; my %hash_rec = (id => "001"); doSub2($hash_rec{id2}); print "main: id2 = $hash_rec{id2}\n"; sub doSub2 { $_[0] = "Hello alias"; }
Prints:
main: id2 = Hello alias
We don't usually take advantage of that trick because without due care it's likely to lead to hard to maintain code.
In reply to Re^3: Sub hash param by reference
by GrandFather
in thread Sub hash param by reference
by hankcoder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |