while ( (print "Enter Number: "), (my $line=) !~ /^\s*d(?:one)?\s*$/i ) { next if $line =~ /^\s*$/; #re-prompt on blank lines ... chomp($line); ... }