Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Regex help - butchering text into paragraphs

by mwah (Hermit)
on May 02, 2008 at 22:42 UTC ( [id://684274]=note: print w/replies, xml ) Need Help??


in reply to Regex help - butchering text into paragraphs

Throop:
Is this the thing that can /should be done in a single golfed line? Alternatively, is there a module that I should be looking at?

Is this part of a larger project? Then, golf wouldn't make much sense.

A simple way, in addition to the solution already posted, would combine the keys into a search expression.

From your description, it isn't completely clear (for me) what you are trying to do. I'll give my alternative below:

# ==> $keyptr, @inputs as in your code my $rg = join'|', map quotemeta, keys %$Keyptr; my @hits; push @hits, { /($rg):(.+?)(?=(?:$rg)|$)/g } for @inputs ; # thats it

You could dump the result w/the following loop:

... for my $rec (@hits) { print "====\n"; print "$_ => $rec->{$_}\n" for sort keys %$rec } ...

This would print then:

==== ANALYSIS => yada ^M yada CONCLUSION => drone drone ^M PREFACE => mumble ^M REMARKS => ixnay ==== ANALYSIS => Chuckle DEFERRED => blahblah ^M blah ^M NAME / NUMBER => John 369 REMARKS => Yada2

Regards

mwa

Log In?
Username:
Password:

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

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

    No recent polls found