foreach my $line (@arr) { ## stuff goes here; } #### for (my $x = 0; $x < $#arr; $x++) { my $line = $arr[$x]; ## stuff goes here; }