|
|
| Don't ask to ask, just ask | |
| PerlMonks |
Re^2: changing the position of an element in an arrayby nobull (Friar) |
| on Nov 17, 2005 at 12:48 UTC ( [id://509497]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
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
|
|
||||||||||||||||||||||||