Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Finding a Block of Text in a Larger Block of Text

by kennethk (Abbot)
on Oct 13, 2011 at 16:28 UTC ( #931303=note: print w/replies, xml ) Need Help??

in reply to Finding a Block of Text in a Larger Block of Text

I would suggest breaking this down as follows:
  1. Write a parser that transforms a generic ADD RULE statement into a useful data object. This could just be a hash/hashref or an object (see Moose) if you want more functionality. This will allow you to more easily determine if objects have similar content.
  2. Read in the full rule set and treat it one rule at a time. This is definitely a TIMTOWTDI moment. I would enable slurp mode (local $/;, see $/ in perlvar) and then split the input into blocks and iterate over them (for (split /\n(?=ADD RULE$)/m) {...}), stashing the parsed objects into an array for later comparison. You could easily accomplish this a number of different ways.
This should give you plenty to get started.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2022-08-13 18:44 GMT
Find Nodes?
    Voting Booth?

    No recent polls found