Perl Programming/Keywords/unshift

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Previous: unpack Keywords Next: untie

The unshift keyword[edit | edit source]

unshift does the opposite of shift. It prepends list to the front of the array and returns the new number of elements in the array.

Syntax[edit | edit source]

  unshift ARRAY, LIST
  unshift EXPRESSION, LIST

Example[edit | edit source]

unshift(@ARGV, '-e') unless $ARGV[0] =~ /^-/;

See also[edit | edit source]

Previous: unpack Keywords Next: untie