you can also use last unless $line; to quit the loop, but this breaks if 0 is passed. If 0 is valid you can last unless defined $line;The last unless defined $line; statement will not work either, because even if $line is empty, it will still be defined.
Your original solution, i.e. last if $line=~/^$/; (or length $line ...), is definitely better.
In reply to Re^2: Empty STDIN does not exit while loop
by Laurent_R
in thread Empty STDIN does not exit while loop
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |