Mega Code Archive

 
Categories / Perl / Array
 

Remove first element only and save it

#!/usr/bin/perl -w @array = (1,2,3,4,5,6,7,8,9); print "@array\n"; $offset = 0;  # first element $length = 1; ($first) = splice(@array, $offset, $length); print "@array\n"; print "First element: $first\n";