while(1) { my $input = <>; chomp $input; check_input('ptype', $input); } BREAK: ... # sub check_input if ($input eq 'b') { goto BREAK: }