use strict; use warnings; open my $fh, "test.txt" or die $!; foreach (;<$fh>;){ print " $. :$_ \n"; }