A more perlish way to do this, and the way that confines your variable to the scope of the loop, is like this:
while( my $nextline = <IN> ){ chomp; last unless $nextline eq ''; # exits the loop unless empty line print "Nextline is empty\n"; } # now $nextline goes out of scope
UPDATE: Yes, as cheekuperl noticed, that should be chomp $nextline;
Aaron B.
Available for small or large Perl jobs; see my home node.
In reply to Re: While loop conditions in Perl
by aaron_baugher
in thread While loop conditions in Perl
by joemaniaci
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |