
japhy
Enthusiast
Jan 23, 2001, 10:03 AM
Post #4 of 8
(879 views)
|
|
Re: Comparing line against line in a foreach loop
[In reply to]
|
Can't Post
|
|
DO NOT READ FILES INTO ARRAYS. That is inefficient, and leads to more inefficient code. As per your modification, it's very simple:
my (%count, @repeated); open IP, $ip_file or die "can't read $ip_file: $!"; while (<IP>) { next unless /^from (\d+\.\d+\.\d+\.\d+)/; push @repeated, $1 if ++$count{$1} == 4; } close IP; There you go. Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author
|