Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Detect presence of numbers 1-9

by Dog and Pony (Priest)
on Apr 08, 2002 at 09:20 UTC ( [id://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]+$/
or
$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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-25 23:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found