my $input; INPUT: { print 'number> '; chomp($input = ); redo INPUT unless $input && $input=~/\A[0-9]+\z/; } print $input, "\n";