in reply to Array of variables
This line:
@arry = ( $one, $two, $three );
...is creating a copy of the values stored in $one, $two, and $three. But they're just copies; the variables are in no way linked to the array itself.
You probably want to pass references to $one, $two, and $three. That way @arry would hold references to those variables, not copies of their contents:
@arry = ( \$one, \$two, \$three ); ${$arry[1]}++; # Increment the referent's value. print "two is $two\n"; print '$arry[1] is: ', $arry[1], "\n"; print '${$arry[1]} is: ', ${$arry[1]}, "\n";
See perlref, but first perlreftut.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array of variables
by dbuckhal (Chaplain) on May 28, 2013 at 20:49 UTC | |
by frozenwithjoy (Priest) on May 28, 2013 at 20:54 UTC | |
by dbuckhal (Chaplain) on May 28, 2013 at 21:06 UTC | |
by frozenwithjoy (Priest) on May 28, 2013 at 21:30 UTC | |
by dbuckhal (Chaplain) on May 28, 2013 at 21:39 UTC |