sub check_input { my ($input, $opts_href) = @_; return $input if length($input) != 1; exit if $input =~ m/Q|c/; $opts_href->{$input}->() if defined $opts_href->{$input} && ref $opts_href->{$input} eq 'CODE'; } ... # define non-global options hash in menu scope my %opts_hash = ( a => sub { goto SOMESPOT }, o => sub { print "continue? (y/N): "; $input = input(); pop @working if $input =~ m/^y$/i; }, 'default' => sub { say "error: please select 'a', 'o', or 'c'" }, ); ... # cannot find this label! sub elsewhere { ... SOMESPOT: ... }