Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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.

Comment on Re: Not exactly Dereferencing... but in that ball park
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://510102]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (15)
As of 2016-02-11 20:12 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (379 votes), past polls