Perl array pop, push, shift, unshift

This is a notice about the array manipulation in Perl, but you should try to avoid to manipulate if you just could iterate troth the array, this is much faster, for this look at Perl shift iterate Benchmark.



remove and return the last element of the array.


add an element to the end of the array.


remove and return the first element of the array.


add an element to the start of the array.


Code example:


Prints this:

4 thoughts on “Perl array pop, push, shift, unshift”

Leave a Reply

Your email address will not be published.

seven + 1 =