in reply to A better understanding of while () loops
Update: fixed a small error.my @acceptable = ('good', 'bad', 'iffy'); while(<>) { chomp; my $input = $_; foreach (@acceptable) { next unless $_ eq $input; print "You are feeling $_!"; undef $input; last; } unless( $input) { print "You didn't give an acceptable answer! Try again:\n"; } }
|
|---|