home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

3.2.112 push

push 

ARRAY

, 

LIST

This function treats ARRAY as a stack, and pushes the values of LIST onto the end of ARRAY . The length of ARRAY increases by the length of LIST . The function returns this new length. The push function has the same effect as:

foreach $value (

LIST

) {
    $ARRAY[++$#ARRAY] = $value;
}

or:

splice @ARRAY, @ARRAY, 0, 

LIST

;

but is more efficient (for both you and your computer). You can use push in combination with shift to make a fairly time-efficient shift register or queue:

for (;;) {
    push @ARRAY, shift @ARRAY;
    ...
}

See also pop and unshift .











??????????????@Mail.ru