in reply to Re^2: a reference by any other name...
in thread a reference by any other name...
If there isn't an appropriate, simple way to do this I'm going to be very surprised.
You can do it pretty easily with package variables:
@array1 = 0..9; *array2 = *array1; pop @array1; print "@array2\n"; pop @array2; print "@array1\n"
But I think the flaming death risk is pretty high here, too, though for different reasons.
Update: you can also use a similar technique to alias to a reference, though again the alias is a package variable, and as such carries all the associated caveats. Example:
sub foo { my ($ref) = @_; local *nonref = $ref; pop @nonref; print "@$ref\n"; pop @$ref; print "@nonref\n"; } foo([ 0 .. 9 ]);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: a reference by any other name...
by Aristotle (Chancellor) on Feb 20, 2006 at 03:08 UTC | |
|
Re^4: a reference by any other name...
by blogical (Pilgrim) on Feb 20, 2006 at 03:33 UTC |