Mega Code Archive

 
Categories / Perl / Array
 

A program that demonstrates the use of an array slice

#!/usr/local/bin/perl  @array = (1, 2, 3, 4);  @subarray = @array[1,2];  print ("The first element of subarray is $subarray[0]\n");  print ("The second element of subarray is $subarray[1]\n");