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

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.

davis
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2014-07-14 10:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (257 votes), past polls