in reply to References
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'; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re (tilly) 1: References
by Cine (Friar) on Aug 19, 2001 at 21:18 UTC | |
by tilly (Archbishop) on Aug 19, 2001 at 21:44 UTC | |
by Cine (Friar) on Aug 20, 2001 at 10:28 UTC | |
by tilly (Archbishop) on Aug 20, 2001 at 15:58 UTC | |
by dragonchild (Archbishop) on Aug 20, 2001 at 16:35 UTC | |
by Cine (Friar) on Aug 20, 2001 at 17:46 UTC | |
|