while ( ) { chomp($input = $_); if ( $input =~ /^okay\b/i ) { print "Y" } } # script continues here when STDIN is exhausted