@digits = (11..21);
@slice[10..20] = (@digits);
print "@slice\n";
print "last index is $#slice.\n";
@09 = (0..9);
@slice[@09] = (@digits);
print "@slice\n";
print "last index is $#slice.\n";
@slice[1,3,5,7,9] = (2,4,6,8,10);
@evenNumbers = @slice[1,3,5,7,9];
print "array: @evenNumbers\n";
print "The last index is $#evenNumbers.\n";
@slice[@digits,77,55,33] = (1,2,3,4,4,5,6,6,7,5,6,7,6,7,8);
print "array are: @slice\n";
print "Indexes 55, 33, 77, and 12 in that order are: @slice[55,33,77,12]\n";
print "The last index of the array is $#slice.\n";
@names = (David, Mary, Thomas, Dewey, Steve, Martin);
printNames(@names);
for ($i=0; $i<=$#names; $i= $i+2){
@names[$i+1, $i] = @names[$i, $i+1];
}
printNames(@names);
sub printNames (@){
my (@names) = @_;
for ($i=0; $i<= $#names;){
print "$names[$i++], $names[$i++]\n";
}
}
|