Perl Learning - 4 (pop/push/shift/unshift, foreach, $_)
@array=qw#dino fred barney#; $m=shift(@array);# $m is 'dino', @array now is ('fred', 'barney')$n=shift @array;# $n is 'fred', @array now is ('barney')
shift @array; # @array now is empty ()
$o=shift @array;# @array still empty, $o is undef
unshift(@array, 5);# @array becomes (5)
unshift @array,4;# @array becomes (4, 5)
@others=1..3;
unshift @array,@others;# @array becomes (1, 2, 3, 4, 5)
页:
[1]