This probably isn't the most efficient algorithm for this type of thing, but it wouldn't surprise me if it was faster than your version using shell tools.use warnings; use strict; use Data::Dumper; my $message_log = "/var/log/messages"; my %messages = ( error => {}, alert => {}, warning => {}, ); open(my $logfile, "<", $message_log) or die "Unable to open $message_log: $!\n"; foreach my $type (keys(%messages)) { seek $logfile, 0, 0; foreach my $line (<$logfile>) { $messages{$type} .= $line if($line =~ /$type/); } } close($logfile); print Dumper(\%messages);
In reply to Re: Not exactly Dereferencing... but in that ball park
by davis
in thread Not exactly Dereferencing... but in that ball park
by jcpunk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |