in reply to Re^2: Not exactly Dereferencing... but in that ball park
in thread Not exactly Dereferencing... but in that ball park
my %messages = map { $_ => [] } qw(error alert warning); my $logfile = '/var/log/messages'; open my $log, "<", $logfile or die "$logfile: open: $!"; while (<$log>) { for my $type (keys %messages) { push @{ $messages{$type} }, $_ if /$type/; } } close $log or die "$logfile: close: $!"; # as long as we're bothering +with explicit close, we may as well test it for success.
I know you know it, but there's no reason to \Q the type names here since they don't contain dangerous characters.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Not exactly Dereferencing... but in that ball park
by Tanktalus (Canon) on Nov 20, 2005 at 01:07 UTC | |
by gaal (Parson) on Nov 20, 2005 at 05:50 UTC |