James Edward Gray II wrote:
> 
> On Mar 31, 2004, at 3:09 PM, James Edward Gray II wrote:
> 
> > On Mar 31, 2004, at 3:02 PM, James Edward Gray II wrote:
> >
> >> On Mar 31, 2004, at 2:50 PM, Price, Jason (TLR Corp) wrote:
> >>
> >>> I am working on a script that searches through a log file, looking
> >>> for IP matches based on several ranges of IPs.  I'm trying to find a
> >>> way to do something like this:
> >>>
> >>> @results = grep /192.168.0.[192-254]/, @list
> >>
> >> @results = grep m/192.168.0.\d{3}/ and $1 >= 192 and $1 <= 254, @list;
> >
> > Sorry to reply to my own message, but I believe I made a mistake up
> > there.  I think you have to switch those ands to &&s.  Sorry about
> > that.
> 
> Egad, I forget the parens around the \d{3} too.  Use Paul's solution.
> It's what I meant, minus about five mistakes.  I must be dumb today.

And you (and Paul) forgot to backslash the dots.

@results = grep { /192\.168\.0\.(\d{3})/ and $1 >= 192 and $1 <= 254 } @list;


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to