use Getopt::Std; && the BLOCK: for ($thing) { /^(?:help)/ && { system "grep \&\& $0"; last BLOCK; }; /^(?:quit|exit|logout|stop)/ && do { die "bye!\n"; last BLOCK; }; # otherwise... print "huh!?\n"; }