However personally I would use the following solution instead as the best mix of safe, efficient, and readable programming with references:# Abuse the symbol table. This does not work under strict. sub a1 { local *c = shift; $c{a} = 'a'; } # Copy the hash by force. Very inefficient. sub a2 { my $ref = shift; my %c = %$ref; $c{a} = 'a'; %$ref = %c; }
TIMTOWTDI.# "Arrow" notation. sub a3 { my $ref = shift; $ref->{a} = 'a'; } # Or compactly sub a4 { (shift)->{a} = 'a'; }
In reply to Re (tilly) 1: References
by tilly
in thread References
by Cine
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |