Jump to content

Perl Programming/Keywords/push

From Wikibooks, open books for an open world
Previous: prototype Keywords Next: q

The push keyword

[edit | edit source]

The push function treats ARRAY as a stack by appending LIST values to ARRAY. Returns the number of elements in the ARRAY after push is completed.

From Perl 5.14.0 onwards, a scalar EXPRESSION can be passed that should hold a reference to an unblessed array. The argument is dereferenced automatically. This is a highly experimental aspect of push and may change in future Perl versions.

Syntax

[edit | edit source]
  push ARRAY, LIST
  push EXPRESSION, LIST

See also

[edit | edit source]
Previous: prototype Keywords Next: q