in reply to Break up weblogs
Create an hash of department => IO::File object for that department's log. Read through the main log, determinining what department the entry is for and printing to the corresponding object.
my %handles; for my $dept ( @departments ) { $handles{ $dept } = IO::File->new; $handles{ $dept }->open( "> $logdir/$dept.log" ) or die "Open failed +: $!\n"; } while( <INLOG> ) { my $dept = divine_department( $_ ); $handles{ $dept }->print( $_ ); }
|
|---|