$ perl -we ' my @array = qw( file1 file2 file3 ); foreach my $i ( 0 .. $#array ) { print "\$i = $i\n" }' $i = 0 $i = 1 $i = 2