Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by suaveant (Parson)
on Jun 26, 2009 at 14:56 UTC ( #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? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2022-09-27 05:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (118 votes). Check out past polls.

    Notices?