in reply to and a simple reg exp poser

Solved without a regex so it's even clearer

if ( -1 != index $log, '198.167.1.10' ) { push @ip, $log; # or... print $log # or whatever makes sense for you } # OR just written differently push @ip, $log if -1 != index $log, '198.167.1.10'; print $log if -1 != index $log, '198.167.1.10'; # Or... as a regexp but I prefer it the other way push @ip, $log if $log =~ /198\.167\.1\.10/; print $log if $log =~ /198\.167\.1\.10/;

Update Ok, maybe a regex is better because then then it can be written like /198\.167\.1\.10(?!\d)/ which would fix the problem Abigail-II pointed out.


Seeking Green geeks in Minnesota

Replies are listed 'Best First'.
Re: and a simple reg exp poser
by Abigail-II (Bishop) on Jan 30, 2003 at 23:03 UTC
    That would capture lines containing 198.167.1.103.

    Abigail