Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Multiline RegExp. A Better Way?

by NetWallah (Canon)
on Feb 16, 2012 at 04:54 UTC ( [id://954145]=note: print w/replies, xml ) Need Help??


in reply to Multiline RegExp. A Better Way?

This one is light on memory, and does not need modules .

Basically, it uses the "Pass #" as a record delimiter.

use strict; use warnings; my $file = "data1.txt"; local $/ = "\nPass #"; open my $fh, '<', $file or die "Can't open $file: $!"; while ( <$fh>){ print join(",", m/(\d+).*? ^Elapsed\ Time\s+:\s+([\d\.]+).*? ^CPU\ Time\s+:\s+([\d\.]+).*? ^Virtual\ memory\ size\s+:\s+([\d\.]+).*? ^Resident\ set\ size\s+:\s+([\d\.]+).*? ^Major\ page\ faults\s+:\s+([\d\.]+) /msgcx) , "\n"; } close $fh;

            “PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil perpetrated by skilled but perverted professionals.”
        ― Jon Ribbens

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-26 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found