BOLCATO CHRIS (esm1cmb) wrote: > This may be a dumb question, but why will this loop not end when > nothing is entered in STDIN? > > print "Enter Things:\n"; > while (<STDIN>) { > print "I saw $_"; > } > print "The End\n";
By "nothing is entered", I assume you mean pressing the Enter key alone. But that's not "nothing", it's "something" (a blank line, with a \n terminator). In order for the loop to terminate, it needs to see an eof condition on STDIN. You can usually signal this on Unix-ish systems with Ctrl-D (or whatever other character your terminal driver has been set to, typically with 'stty eof'). Or, if you want the loop to terminate when a blank like is entered, you need to add something like this inside your loop: last unless /\S/; # end if only whitespace (or empty) line -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>