in reply to Re: Regexp for range of numbers
in thread Regexp for range of numbers

That doesn't work. Interpolation happens before the regex is performed, so your $1 refers to a previous succesful match:
#!/usr/bin/perl use strict; use warnings; while (<DATA>) { chomp; printf "%d %s\n", $_, /^(\d{1,3})${\($1 > 255 ? qr(^) : qr($))}/ ? "matches" : "fails"; } __DATA__ 3 100 333 200 Use of uninitialized value in numeric gt (>) at XXX line 9, <DATA> lin +e 1. 3 matches 100 matches 333 matches 200 fails

Replies are listed 'Best First'.
Re^3: Regexp for range of numbers
by Roy Johnson (Monsignor) on Apr 05, 2005 at 12:55 UTC
    Yes, I've had a notice to that effect at the top of the post for about an hour.

    Caution: Contents may have been coded under pressure.
      Yeah, I noticed. What happened was that I started writing my reply, was almost finished, called away to put out a fire somewhere, went to lunch, came back, finished my reply, and hit submit.

      The time on top of a node is the time the finished reply reaches the server, not the time someone starts composing. ;-)

        I was just hoping you hadn't been testing my code for an hour! :-O

        Caution: Contents may have been coded under pressure.