Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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 wandering the Monastery: (4)
As of 2018-02-24 11:15 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (310 votes). Check out past polls.