in reply to While(defined(STDIN)) does not break

Further to Corion's advice, I have used this code structure in the past when prompting for user input that is terminated by CTRL+D (or CTRL+Z and ENTER). It clears away your last prompt before returning to the shell to make things look a bit tidier.

use strict; use warnings; my $prompt = q{Please enter your response (CTRL+D to exit): }; my $dePrompt = qq{\r} . q{ } x ( length( $prompt ) + 2 ) . qq{\r}; my $responseCt = 0; while( 1 ) { print $prompt; last if eof STDIN; $_ = <STDIN>; chomp; $responseCt ++; print qq{Response $responseCt, "$_"\n}; } print $dePrompt;

I hope this is of use.

Cheers,

JohnGG