Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

(boo) Regexp'ing through a logfile

by boo_radley (Parson)
on Mar 27, 2001 at 22:27 UTC ( #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? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2022-12-10 03:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?