in reply to Are two lines in the text file equal
If you want really fast (and have a lot of memory like 1-4GB) use a hash thusly:
my $log1 = '/var/log/httpd/access_log'; my $log2 = '/var/log/httpd/access_log.1'; my %hash; open FH1, $log1 or die $!; open FH2, $log2 or die $!; $hash{$_}++ while <FH1>; $hash{$_}++ while <FH2>; close FH1; close FH2; for (keys %hash) { print if $hash{$_} > 1; }
Any key with a count > 1 is a match.
Expect this to use about 200-400 MB of memory per million lines as a ballpark (at least double, maybe even triple the raw data size). With Perl you spend memory for speed. Because of the time stamps, ips, etc you may want to parse out the part you really want to see similar (which will also save memory as the keys will be much shorter).
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Are two lines in the text file equal (!count)
by tye (Sage) on Nov 13, 2003 at 02:38 UTC | |
by BrowserUk (Patriarch) on Nov 13, 2003 at 03:09 UTC | |
by prostoalex (Scribe) on Nov 13, 2003 at 07:05 UTC | |
by PodMaster (Abbot) on Nov 13, 2003 at 12:29 UTC | |
by BrowserUk (Patriarch) on Nov 13, 2003 at 22:27 UTC |