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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Detect presence of numbers 1-9
by demerphq (Chancellor) on Apr 08, 2002 at 10:17 UTC | |
Re: Re: Detect presence of numbers 1-9
by Dog and Pony (Priest) on Apr 08, 2002 at 09:20 UTC | |
by dragonchild (Archbishop) on Apr 08, 2002 at 14:27 UTC | |
Re: Re: Detect presence of numbers 1-9
by Juerd (Abbot) on Apr 08, 2002 at 09:37 UTC | |
Re: Re: Detect presence of numbers 1-9
by tachyon (Chancellor) on Apr 08, 2002 at 09:57 UTC |
In Section
Seekers of Perl Wisdom