in reply to While loop conditions in Perl

while (defined my $line = <IN>) { # read all data in one while(){} chomp $line; # remove \n from the end of the line next if $line eq ''; # skip empty lines ... }
EDIT: chomp instead of chop
Sorry if my advice was wrong.

Replies are listed 'Best First'.
Re^2: While loop conditions in Perl
by Anonymous Monk on Jul 19, 2012 at 14:38 UTC

    chop is going to truncate your data if you don't have a \n on the last line.

    Are you sure that you'll be getting \n after every line ever?

      Sorry! It was a misprint. chomp will do it better.
      Sorry if my advice was wrong.