Flame has asked for the wisdom of the Perl Monks concerning the following question:
Is it possible to reference a specific array element? For instance:
my @array = (21..102); my $ref = \$array[5]; $$ref = 4; print $array[5];
Essentially I want to be able to pass this reference to an element of the array to a sub for editing. Or more precicely, I want to go through the array one element at a time and pass one argument at a time to another function for modification. Any idea how I would go about this? Is it even allowed? While I do use normal refs on a regular basis, this is something I'm clueless for... so any help would be appreciated, down to a technical explanation of how they do referencing in perl. (I'm curious but I lack the skill in other languages to actually understand how perl itself was written... hehe)
Thank you for any assistance or advice as to other ways I could achieve this.
Note: I actually did try the equivilant of the above... yielded things like \45 instead of a reference...
My code doesn't have bugs, it just develops random features.
Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reference to array element?
by gjb (Vicar) on Jan 30, 2003 at 01:59 UTC | |
by Flame (Deacon) on Jan 30, 2003 at 02:27 UTC | |
by Flame (Deacon) on Jan 30, 2003 at 02:14 UTC |