Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Parsing Log File Help!

by Enlil (Parson)
on Apr 14, 2004 at 19:54 UTC ( [id://345178]=note: print w/replies, xml ) Need Help??


in reply to Parsing Log File Help!

For starters, I would doubt that your regex is doing what you think it is doing because in essence it can be reduced to:
/^(.+)$/
(/i is unnecessary as . does not care about case, and /g is not necessary as you will only match the start(^) and end($) once per line as you don't have a /m (if you were dealing with multiline strings), also once it has matched once the conditional is true regardless) and the only difference between your regex and mine would be that in the latter the entire line would be put into $1 instead of $8. Which brings us to the case as to why the name of the element won't show up. It is in $8 not $1. But since it matches you push an empty string each time on to @logg. So then latter when you hashify it end up with one element in the hash (being an empty string), with a total count of however many lines were in your file. Regardless not knowing what you file looks like or what represents an element (i.e. what is supposed to go in $1 .. $8.), we can't further help you on how to rectify the situation.

update:Upon looking at it further the .+ should actually be actually .*, in which case $1 would be an empty string for empty lines, me changing it to a plus would have skipped blank lines which is different behaviour from what the regex the OP posted.

-enlil

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-19 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found