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;


How's that?

Which, obviously, doesn't work. Is there any way to specify a range of multi-digit numbers in a regular expression?

@results = grep m/192.168.0.(?:19[2-9]|2[0-4]\d|25[0-4])/, @list;


I think that works too, but I don't think it's as simple as the above. Season to taste. ;)

James


-- 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