my $filename = 'output.txt'; open my $fh,'<',$filename or die "Could not open $filename : $!"; while (<$fh>){ # process lines }