Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Ok, it's not a huge issue and has an easy workaround, but I'm curious as to why this does not work. I want to break out of the while loop if an empty string is entered to STDIN. Am I missing something obvious due to sleep deprivation or lack of caffeine?
print " > "; while (chomp( my $line = <STDIN>)){ print " [$line]\n"; } print " > ";
I'm not looking for a solution, I already have that. Just wondering why this doesn't work
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Empty STDIN does not exit while loop
by choroba (Cardinal) on May 20, 2017 at 07:59 UTC | |
Re: Empty STDIN does not exit while loop
by Discipulus (Canon) on May 20, 2017 at 07:37 UTC | |
by Laurent_R (Canon) on May 20, 2017 at 08:48 UTC | |
Re: Empty STDIN does not exit while loop
by haukex (Archbishop) on May 20, 2017 at 08:28 UTC | |
Re: Empty STDIN does not exit while loop
by Marshall (Canon) on May 20, 2017 at 09:14 UTC | |
Re: Empty STDIN does not exit while loop
by BillKSmith (Monsignor) on May 20, 2017 at 13:37 UTC | |
Re: Empty STDIN does not exit while loop
by johngg (Canon) on May 20, 2017 at 10:22 UTC |