http://www.perlmonks.org?node_id=157391


in reply to Detect presence of numbers 1-9


You could use a regex to either match the characters that you want or alternatively to not match the characters that you don't want:
#!/usr/bin/perl -wl use strict; my $scalar = '1335'; print "Found" if $scalar =~ /^[1-5]+$/; print "Found" if $scalar !~ /[^1-5]/;

--
John.