in reply to Aliasing values, not variables
Sorry for not coming up with this ugly solution while you were asking about it in the CB:
#!/usr/bin/perl -w use strict; sub alias{ \@_ }; my @a = (1,"world"); my $arr = alias( $a[0], $a[0], $a[1] ); $arr->[0] = "hello"; print "@$arr\n";
I learned this ugly trick from demerphq while he was testing the aliasing features of his DDS module, so maybe looking at what the dumpers and their tests do might give you some more inspiration.
Updated: Fixed typo in sub alias, spotted by nothingmuch
Updated: I use strict; but the code won't run like that. That should teach me about posting when I don't cut'n'paste my code ... Spotted by The Mad Hatter
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Aliasing values, not variables
by japhy (Canon) on Jul 18, 2004 at 16:23 UTC | |
by Corion (Patriarch) on Jul 18, 2004 at 16:31 UTC | |
by japhy (Canon) on Jul 18, 2004 at 16:43 UTC |
In Section
Seekers of Perl Wisdom