in reply to A better understanding of while () loops

If you are looking to match exact words, then you might consider solving this problem with a hash instead:

my %moods = ( good => "Glad you are doing well!\n", bad => "Oi, that's not good to hear!\n", iffy => "At least you're undecided...still hope after all.\n", ); while (1) { print "Are you having/had a good, bad, or iffy day $name?: "; chomp( my $input = <STDIN> ); # assuming case-insensitive: next unless exists $moods{ lc( $input ) }; print $moods{ lc( $input ) }; last; }

update: wfsp beat me to it.