in reply to Re: Befuddled by The Llama
in thread Befuddled by The Llama
The given situation is perfect for a do-while loop to avoid the need to read from stdin in more than one place...
{ my $count = 0; do { print "\nPlease enter a number: "; $in[$count++] = <STDIN>; } while ( $in[-1] !~ m/q/i ); pop @in; # Remove 'quit signal' } chomp @in;
...but i would personally prefer something like...
while ( 'reading...' ) { print "\nPlease enter a number: "; my $in = <STDIN>; do { push @in , $in; next; } unless $in =~ m/q/i; last; } chomp @in;
|
---|