perl中shift 和unshift 操作
unshift 和shift 对一个数组的开头进行操作(数组的左端有最小下标的元素)。
unshift 和shift,如果其数组变量为空,则返回undef。
#!/usr/bin/perl -w
@array = qw#one two three#;
KaTeX parse error: Expected 'EOF', got '#' at position 23: …ft (@array); #̲m 得到“one”, @array 现在为(“two”, “three”)
shift @array; #现在为(“three”)
shift @array; #现在为空
KaTeX parse error: Expected 'EOF', got '#' at position 24: …t @array; #̲n 得到undef, @arry 仍为空
unshift(@array,5); #现在为(5)
unshift @array,4; #现在为(4,5)
@others = 1…3;
unshift @array, @others; #array 现在为(1,2,3,4,5)