sub check_input { my ($type, $input) = @_; return $input if length($input) != 1; exit if $input eq 'q'; # etc for universal options # handle prompt types if ($type eq 'start') { if ($input eq 'n') { # do something useful with currently out-of-scope variables ... # (uh oh) } } # etc, etc }