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

Re: Regexes, stitching broken lines, and other fun stuff.

by suaveant (Parson)
on Jun 26, 2009 at 14:56 UTC ( [id://775075]=note: print w/replies, xml ) Need Help??


in reply to Regexes, stitching broken lines, and other fun stuff.

There are many ways to do it... you could use a single regexp
$file =~ /^\s+spg-risk-\S+\s+.*? IN \d{8}\/\d\s*$/ms;
That should match a "full line" Or as you said, use state...
my $last; while(<IN>) { if(/^\s+(spg-risk\S+)/) { $items{$1} = $_; $last = $1; } elsif($last) { $items{$last} .= $_; } else { warn "Extended line found before any items found\n"; } }
Not tested, but should give you an idea.

                - Ant
                - Some of my best work - (1 2 3)

Log In?
Username:
Password:

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

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

    No recent polls found