Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Parsing a log file

by nuance (Hermit)
on Jul 13, 2000 at 00:19 UTC ( #22269=note: print w/replies, xml ) Need Help??

in reply to Parsing a log file

You've said you know how to read the files and get the lines etc. so I'm just going to do the other bits.

First you want to split the data to extract the path to the file and the number at the end. You can use split to do this:

my @bits = split ' ', $line;

This will give you and array with the path to the file in $bits[3] and the number in $bits[4]. Next you must extract the file type from the path to the file.

$bits[3] =~ s/\.(\w+)$/$1/;

I would then use a hash to store these:


The first time you reference a type/ number combination it will be created with a value of one, each time after that the number gets incremented and so it keeps a count of how many times each combination occurred. At the end of the script you can get the data with:

foreach $type (keys %count) { foreach (keys %count{$type}) { print "$type $_ $count{$type}{$_}"; } }


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-05-28 20:15 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (101 votes). Check out past polls.