while ( <> ){ for (my $i=0; $i<=$#file_names; $i++){ ... } }