open(my $infile, '<', $inputfile) or die "Could not open $inputfile because $!\n"; while(<$infile>){ next if /^\s*$/; chomp; # you don't want the newline, do you? #processing follows here... } close($infile); }