![]() |
|
Do you know where your variables are? | |
PerlMonks |
Re^2: changing the position of an element in an arrayby nobull (Friar) |
on Nov 17, 2005 at 17:48 UTC ( #509497=note: print w/replies, xml ) | Need Help?? |
Actually a simple splice/push will not change the position of an element in an array, it will create a new element that comtains a copy of the value from the old of element.
Had $array[1] been moved to the end of the array then $$ref_to_element would point to $array[2] after the move. Admittedly, this is usually not an issue. On the rare occasions when you really want to move elements of an array use Array::Splice. In the above example you would use push_aliases() in place of the built-in push().
In Section
Seekers of Perl Wisdom
|
|