in reply to Pattern Matching Again - IP Addy

hum, it works for me...

while (<DATA>) { if (length($_) > 10) { if ($_ =~ (m/192\.168\./g)) { $readlines++; } } } print($readlines, $/); # prints 3, although you're probably expecting it to be 2. __DATA__ 192.168.0.1 1.192.168.0 12345678901 dfhasfhasdjk 192.168.33.4

The /g is unecessary, misleading, and a potential cause of problem. The $_ is the default argument for both length and m//, so it can be omitted:

while (<DATA>) { if (length && /192\.168\./) { $readlines++; } } print($readlines, $/); # prints 3, although you're probably expecting it to be 2. __DATA__ 192.168.0.1 1.192.168.0 12345678901 dfhasfhasdjk 192.168.33.4

Replies are listed 'Best First'.
Re^2: Pattern Matching Again - IP Addy
by monger (Friar) on Nov 18, 2004 at 14:50 UTC
    Thanks ikegami. That did the trick!
    monger
    Monger +++++++++++++++++++++++++ Munging Perl on the side