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

(boo) Regexp'ing through a logfile

by boo_radley (Parson)
on Mar 27, 2001 at 22:27 UTC ( [id://67574]=note: print w/replies, xml ) Need Help??


in reply to Regular Expression Question

While I am annoyed at the presentation of your question, it gave me a chance to abuse $/ in an entertaining fashion. I think I'm either thinking more perly, or going insane. :)
use strict; open LOG, "C:/fs.log"; $/="\n\n"; while(<LOG>){ m |^(\w+)\n|; print "Machine $1\n"; while (m|\n(/.*?\s).*?(\d+)%|gi) { print "\t",$2 > 88? "WARNING --> ":"","$1 at $2 %\n" } }
does the undef need to be there?
Update No, it can be replaced by the "" you see in the ?: .

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2025-07-08 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.