in reply to Matching IP address continued

I've done my very best to replicate both your data and your regexs as you supplied them and all the regexes, including the one I gave you appear to match every line of data.

My results

C:\test>214537 136.1.1.154:33672 -> 64.210.209.51:80 -> 192.168.1.145:80 tcp Matched! Matched! Matched! Matched! Matched! Matched! Matched! 65.201.211.176:14664 -> 64.210.209.54:80 -> 192.168.1.78:80 tc +p Matched! Matched! Matched! Matched! Matched! Matched! Matched! 67.38.95.86:2116 -> 64.210.209.50:80 -> 192.168.1.103:80 tcp Matched! Matched! Matched! Matched! Matched! Matched! Matched! 198.49.222.246:52469 -> 64.210.209.54:80 -> 192.168.1.79:80 tc +p Matched! Matched! Matched! Matched! Matched! Matched! Matched! 193.80.106.152:3781 -> 64.210.209.61:80 -> 192.168.1.81:80 tcp Matched! Matched! Matched! Matched! Matched! Matched! Matched! 67.28.79.24:3248 -> 64.210.209.54:80 -> 192.168.1.79:80 tcp Matched! Matched! Matched! Matched! Matched! Matched! Matched! 128.187.192.39:1218 -> 64.210.209.54:80 -> 192.168.1.78:80 tcp Matched! Matched! Matched! Matched! Matched! Matched! Matched! 128.187.192.39:1209 -> 64.210.209.51:80 -> 192.168.1.144:80 tc +p Matched! Matched! Matched! Matched! Matched! Matched! Matched! sdasjdlk asd lkajslkdjalks8237472934 ajlksdjaser asdlkjaslkd No match! No match! No match! No match! No match! No match! No match!

Which leaves me at a loss to explain your findings?

My test script

#! perl -sw use strict; my $re_ip = qr/(\d+\.\d+\.\d+\.\d+):\d+/; my @re_lines = ( qr/ ^ \s* $re_ip \s* -> \s* $re_ip \s* -> \s* $re_ip /x, qr/^\s*$re_ip\s*->\s*$re_ip\s*->\s*$re_ip/, qr/^ \s* $re_ip\s*->\s*$re_ip\s*->\s*$re_ip/x, qr/^\s*$re_ip\s*-> \s* $re_ip\s*-> \s* $re_ip/x, qr/ ^ \s* $re_ip\s*->\s*$re_ip\s*->\s*$re_ip/x, qr/ ^ \s* $re_ip \s*->\s*$re_ip\s*->\s*$re_ip/x, qr/ ^ \s* $re_ip\s*->\s*$re_ip \s*->\s*$re_ip/x, ); while (my $line = <DATA>) { print $line; for my $regex (@re_lines){ $line =~ $regex ? print ' Matched!' : print ' No match!'; } print $/,$/; } __DATA__ 136.1.1.154:33672 -> 64.210.209.51:80 -> 192.168.1.145:80 tcp 65.201.211.176:14664 -> 64.210.209.54:80 -> 192.168.1.78:80 tc +p 67.38.95.86:2116 -> 64.210.209.50:80 -> 192.168.1.103:80 tcp 198.49.222.246:52469 -> 64.210.209.54:80 -> 192.168.1.79:80 tc +p 193.80.106.152:3781 -> 64.210.209.61:80 -> 192.168.1.81:80 tcp 67.28.79.24:3248 -> 64.210.209.54:80 -> 192.168.1.79:80 tcp 128.187.192.39:1218 -> 64.210.209.54:80 -> 192.168.1.78:80 tcp 128.187.192.39:1209 -> 64.210.209.51:80 -> 192.168.1.144:80 tc +p sdasjdlk asd lkajslkdjalks8237472934 ajlksdjaser asdlkjaslkd

Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

Replies are listed 'Best First'.
Re: Re: Matching IP address continued
by ibanix (Hermit) on Nov 20, 2002 at 19:07 UTC

    This file is a direct dump of data I am looking at.

    My snippet of code looks like:

    ... # Setup our IP matching regex my $re_ip = qr/(\d+\.\d+\.\d+\.\d+):\d+/; my $re_test = qr/^\s*$re_ip\s*->\s*$re_ip\s*->\s* $re_ip/x; my $re_line = qr/ ^ \s* $re_ip \s* -> \s* $re_ip \s* -> \s* $re_ip /x; ... # Reset data my @connections = `bigpipe conn dump`; ... foreach my $line (@connections) { print "$line\n" if ($line =~ /$re_test/); $vip{$2}{'conn_count'}++ if ($line =~ /$re_line/); }

    The print statement works as expected; the increment does not. The increment counter works immediately if I change it to if ($line =~ /$re_test/);

    Thanks again for all the help.

    <-> In general, we find that those who disparage a given operating system, language, or philosophy have never had to use it in practice. <->

      Again, running all the regexes, including the $re_test and $re_line from this post (c&p very carefully) against the entire file you linked, the only line that any of them do not match is the first one.

      from vip node proto

      The next question is what version of Perl are you running and on what OS?


      Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
      Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
      Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
      Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

        Here's what a perl -V gets me:

        Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Platform: osname=bsdos, osvers=4.1, archname=i386-bsdos uname='bsdos bsdi.com 4.1 :bsdos_distribution defined: i386' hint=recommended, useposix=true, d_sigaction=define usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314 (egcs-1. +1.2 release) cppflags='' ccflags ='' stdchar='char', d_stdstdio=undef, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='ld', ldflags =' -L/usr/X11/lib -L/usr/local/lib' libpth=/usr/local/lib /usr/shlib /shlib /usr/lib /usr/X11/lib libs=-ldl -lm -lc libc=/shlib/libc.so, so=so, useshrplib=true, libperl=libperl.so Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynami +c -Wl,-rpath,/usr/libdata/perl5/5.00503/i386-bsdos/CORE' cccdlflags='-fPIC', lddlflags='-shared -x -L/usr/X11/lib -L/usr/l +ocal/lib' Characteristics of this binary (from libperl): Built under bsdos Compiled at Nov 16 1999 17:30:11 @INC: /usr/libdata/perl5/5.00503/i386-bsdos /usr/libdata/perl5/5.00503 /usr/libdata/perl5/site_perl/i386-bsdos /usr/libdata/perl5/site_perl /usr/libdata/perl5/site_perl/i386-bsdos/include .

        My script is already using the regex that works for me, so this is really a non-issue, just one that I thought was odd.



        <-> In general, we find that those who disparage a given operating system, language, or philosophy have never had to use it in practice. <->