open my $handle, '<', $filename or die "Can't open '$filename' for reading: $!"; while (<$handle>){ ... } close $handle