my @arr =(10,11,12);
my $count =1;
foreach my $x (@arr)
{
print $count++," $x\n";
}
#prints
#1 10
#2 11
#3 12
####
while (@tokens)
{
my ($x, $y) = splice(@tokens,0,2);
.....use $x and $y to do something...
..next loop causes another pair of $x, $y to be
used if there are any left in @tokens
}
####
#!/usr/bin/perl -w
use strict;
my @arr = ( 11, 12, 13, 14 );
while (@arr)
{
my $x = shift(@arr);
print "this item=$x #left in arr ".@arr."\n";
}
=prints
this item=11 #left in arr 3
this item=12 #left in arr 2
this item=13 #left in arr 1
this item=14 #left in arr 0
=cut