Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Append one or more elements to ...Add or remove elements anywher ... (Berikutnya)
Functions for real @ARRAYs

Remove the first element of an array, and return it

Daftar Isi

  • shift ARRAY

  • shift EXPR
  • shift

    Shifts the first value of the array off and returns it, shortening thearray by 1 and moving everything down. If there are no elements in thearray, returns the undefined value. If ARRAY is omitted, shifts the@_ array within the lexical scope of subroutines and formats, and the@ARGV array outside a subroutine and also within the lexical scopesestablished by the eval STRING, BEGIN {}, INIT {}, CHECK {},UNITCHECK {}, and END {} constructs.

    Starting with Perl 5.14, shift can take a scalar EXPR, which must hold areference to an unblessed array. The argument will be dereferencedautomatically. This aspect of shift is considered highly experimental.The exact behaviour may change in a future version of Perl.

    To avoid confusing would-be users of your code who are running earlierversions of Perl with mysterious syntax errors, put this sort of thing atthe top of your file to signal that your code will work only on Perls ofa recent vintage:

    1. use 5.014;# so push/pop/etc work on scalars (experimental)

    See also unshift, push, and pop. shift and unshift do thesame thing to the left end of an array that pop and push do to theright end.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Append one or more elements to ...Add or remove elements anywher ... (Berikutnya)