On Wed, 31 Mar 2004 23:09:28 +0200 Paul Johnson <[EMAIL PROTECTED]> wrote:
> On Wed, Mar 31, 2004 at 02:50:30PM -0600, 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 > > > > Which, obviously, doesn't work. Is there any way to specify a range > > of multi-digit numbers in a regular expression? > > Does it really need to be a regular expression? You might consider writing something using the Socket package. It has a routine, inet_aton to convert an Internet address in dotted decimal to its numeric representation. You can then convert your initial address range to two numbers and then convert the dotted decimal representation of each IP address to a number and do a direct numeric comparison. You might also take a look at the CPAN module Net::IP::Match. It looks like it does what you want to do unless you really want to code up your own solution from scratch. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>