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


in reply to Detect presence of numbers 1-9

This looks like a task for a regex:

if ( $scalar =~ /^[12345]+$/ ) { print "match"; } else { print "no match"; }

Update: as crazyinsomniac pointed out you can also write:

if ( $scalar !~ /[^12345]/ ) { print "match"; }

alex pleiner <alex@zeitform.de>
zeitform Internet Dienste