Paul Corr wrote: > > Folks, > > I'd like some feedback on how to best concatenate two Common Log Format > Web server logs. I have two WebSTAR servers mapped to the same hostname. > Each has an access log. I'd like to concatenate them and use WebTrends to > generate a report. WT works fine with individual logs. It chokes on doing > both because the start dates are the same. > > 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. Sounds like you want to do a merge. That should be very simple. open(IN1, "logfile1") or die "Unable to open logfile1: $!\n"; open(IN2, "logfile2") or die "Unable to open logfile2: $!\n"; open(OUT, "outfile") or die "Unable to open outfile: $!\n"; my $in1 = <IN1>; my $in2 = <IN2>; while (defined($in1) and defined($in2)) { if (order($in1, $in2) <= 0) { print OUT $in1; $in1 = <IN1>; } else { print OUT $in2; $in2 = <IN2>; } } print OUT while <IN1>; print OUT while <IN2>; Where order() resembles a sort subroutine, except that it compares $_[0] and $_[1] instead of $a and $b. It should return -1 if $_[0] comes first, 1 if $_[1] comes first, 0 if $_[0] and $_[1] have the same sort order. I would have defined order() above, but I don't know what your data looks like. ;) Ronald ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org