http://qs321.pair.com?node_id=775075


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)