unshift ARRAY, LIST |
LIST替換ARRAY中的元素,按順序為從ARRAY的開頭。這是shift()的相反功能.
數組中的新元素的數量。
#!/usr/bin/perl -w #by www.gitbook.net @array = ( 1, 2, 3, 4); print "Value of array is @array\n" ; unshift( @array, 20, 30, 40 ); print "Now value of array is @array\n" ;
It will produce following results:
Value of array is 1 2 3 4
Now value of array is 20 30 40 1 2 3 4