View Single Post
Old 04-03-2003, 11:25 AM   #2 (permalink)
Talleyrand
Registered User
 
Join Date: Mar 2003
Location: Seattle, WA
Posts: 7
Talleyrand is on a distinguished road
Send a message via ICQ to Talleyrand
I like to use hashes for this ... keeps things (mostly) neat while keeping track of data. Be careful, though, hashes can get out of hand if you go nuts with 2+ dimensions


So like, you'd have some hash %count
Each time what you want is hit, you'd increment the appropriate key...

$count{'this_thing'}++

And if what you're coming across is variable, you can use whatever is set in the variable as a key name ... this works well for pattern matches.

my ( $pattern ) = $log_line =~ /(some pattern)/;
$count{$pattern}++;

Make sense?

Of course, with PERL, there's always more than one way to do it

Hope that helped.

Talleyrand
Talleyrand is offline   Reply With Quote