February 2012
Intermediate to advanced
1184 pages
37h 17m
English
unshiftARRAY,LIST
This function does the opposite of shift. (Or the opposite of push, depending on how you look at it.) It
prepends LIST to the front of the array and
returns the new number of elements in the array:
unshift(@ARGV, "–e", $cmd) unless $ARGV[0] =~ /^–/;
Note the LIST is prepended whole, not
one element at a time, so the prepended elements stay in the same order.
Use reverse to do the reverse.
Starting with v5.14, unshift
can take a reference to an unblessed array, which will be dereferenced
automatically. This aspect of unshift
is considered experimental. The exact behavior may change in a future
version of Perl.
Read now
Unlock full access