Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Re: Detect presence of numbers 1-9

by Dog and Pony (Priest)
on Apr 08, 2002 at 09:20 UTC ( #157393=note: print w/replies, xml ) Need Help??

in reply to Re: Detect presence of numbers 1-9
in thread Detect presence of numbers 1-9

If you do have a sequence like that, you can make it look even cleaner by writing it:
$scalar =~ /^[1-5]+$/
$scalar !~ /[^1-5]/

You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

Replies are listed 'Best First'.
Re3: Detect presence of numbers 1-9
by dragonchild (Archbishop) on Apr 08, 2002 at 14:27 UTC
    I'd avoid the double-negative tests because they would match the empty string (and undef, but you do have warnings enabled, right?). In most cases, it's usually better to state what you want, not what you don't want. :-)

    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://157393]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2021-06-23 04:59 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (114 votes). Check out past polls.