unless( $some_user_input =~ /^(\d+)$/ ) { die "You did not pass only digits for some_input\n"; # or you produce an error page here or send the user back if it's a CGI, f.ex } my $untainted_user_input = $1;