#!/usr/bin/perl -wl use strict; my $scalar = '1335'; print "Found" if $scalar =~ /^[1-5]+$/; print "Found" if $scalar !~ /[^1-5]/;