[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] looking to compare and concatenate Web logs



At 09.08 -0500 1999.04.01, Paul Corr wrote:
>I saw a recipe in the Perl Cookbook on reading a line from the CLF file
>into variables. Basically, I want to read the two files, compare lines on
>the date and time 'fields' and write the lines to an output file
>appropriately. I'm open to suggestions.

Most web logfile anaylzers I've seen don't care if the data is sorted.  You
could just concatenate them into one file.  BBEdit can do this with large
files easily with its Concatenate Files ... tool, and you can do it with
MacPerl like this or something similar:

  @ARGV = ($file1, $file2);   # pretend they are on the command line
  open F, "> newfile" or die $!;
  print F while <>;           # one line at a time print to new file


If you do need the data sorted, you can look at the File::Sort module which
is intended to do stuff like that.  I am rewriting it to mimic the features
of Unix sort now, which gives the flexibility you might need for something
like this.  See http://pudge.net/files/macperl/scripts/sort.pudge for the
current version.  It is a command line tool, but you can just stick
arguments into @ARGV at the top to get the same effect.

I'll be merging the new changes back into File::Sort at some point.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org