use strict; use warnings; my $line; while ( (print "list of letters: "),$line=<>, $line !~ /\s*quit|exit|q\s*$/i) { print "doing something with $line\n"} __END__ Example run: C:\Users\xxx\Documents\PerlProjects\Monks>perl commandloopX.pl list of letters: 234 doing something with 234 list of letters: asdf doing something with asdf list of letters: quit C:\Users\xxx\Documents\PerlProjects\Monks>