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.