in reply to Untangling Log Files
You shouldn't slurp files unless you actually need all of the file in memory at the same time. Your normal action should be to process the file a record at a line.
I'd do something like this:
my %fh; # store handles of new log files open OLDLOG, $path_to_old_log or die $!; while (<OLDLOG>) { my $proc = extract_process_id_from_old_log_record($_); unless (exists $fh{$proc}) { open $fh{$proc}, '>', "$proc.log" or die $!; } print $fh{$proc} $_; }
Update: Reread the first line. It made no sense, so I fixed it.
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Untangling Log Files
by sauoq (Abbot) on Feb 08, 2007 at 16:03 UTC | |
by davorg (Chancellor) on Feb 08, 2007 at 16:08 UTC |