Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Not exactly Dereferencing... but in that ball park

by davis (Vicar)
on Nov 19, 2005 at 15:17 UTC ( #510102=note: print w/replies, xml ) Need Help??

in reply to Not exactly Dereferencing... but in that ball park

The thing you're trying to do is known as "symbolic referencing", and yes, it can be done. You don't want to do it though (there are plenty of nodes around that can tell you why). One better way of doing this would be to use a hash:
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);
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.

Kids, you tried your hardest, and you failed miserably. The lesson is: Never try.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://510102]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2017-03-22 22:35 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (276 votes). Check out past polls.