open my $fh, '<', $filename or die "Cannot open file '$filename' for reading: $!\n"; while ( my $line = <$fh> ) { # Do stuff here. } close $fh;