xorl has asked for the wisdom of the Perl Monks concerning the following question:
The other way I thought was to store each log in a hash first then wirte it to the DEPTLOGmy @dir_list = qw(dept1 dept2 dept3); # actually there are over 40 dep +artments in this list foreach my $dept (@dir_list) { open (DEPTLOG, "+>/data/logs/" . $dept . "current.log"); open (LOGFILE, "/data/logs/access.log"); while (<LOGFILE>) { if (/$dept/) { print DEPTLOG $_; } close(LOGFILE); close(DEPTLOG); }
As I said neither of these seem very good. They both take forever to process. Is there a quicker way to handle this? Thanks.my @dir_list = qw(dept1 dept2 dept3); # actually there are over 40 dep +artments in this list my %logs; open (LOGFILE, "/data/logs/access.log"); while (<LOGFILE>) { foreach my $dept (@dir_list) { if (/$dept/) { $logs{$dept} .= $_; } } close(LOGFILE); foreach my $dept (@dir_list) { open (DEPTLOG, "+>/data/logs/" . $dept . "current.log"); print DEPTLOG $logs{$dept}; close (DEPTLOG); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Break up weblogs
by BrowserUk (Patriarch) on Aug 09, 2004 at 15:37 UTC | |
|
Re: Break up weblogs
by Fletch (Bishop) on Aug 09, 2004 at 15:19 UTC | |
|
Re: Break up weblogs
by xorl (Deacon) on Aug 09, 2004 at 16:11 UTC | |
| |
|
Re: Break up weblogs
by Old_Gray_Bear (Bishop) on Aug 09, 2004 at 15:43 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |