Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Reducing memory usage while matching log entries

by meetraz (Hermit)
on Feb 01, 2006 at 18:30 UTC ( [id://527135]=note: print w/replies, xml ) Need Help??


in reply to Reducing memory usage while matching log entries

Try this:
use strict; my %locks; while (chomp(my $line = <STDIN>)) { next unless ($line =~ /Mutex(.*)::(.*)/); my ($mutex,$action) = ($1,$2); if ($action eq 'locking') { if ($locks{$mutex}) { printf ("Mutex %s already locked on line %d, locked again +on line %d\n", $mutex, $locks{$mutex}, $.); } else { $locks{$mutex} = $.; } } elsif ($action eq 'unlocked') { if ($locks{$mutex}) { delete $locks{$mutex}; } else { printf ("Mutex %s unlocked on line %d, but wasn't locked.\ +n", $mutex, $.); } } } foreach my $mutex (keys %locks) { printf ("Mutex %s locked on line %d, but wasn't unlocked\n", $mutex, $locks{$mutex}); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-25 21:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found