in reply to parsing code, finding block boundaries

You seem to be more interested in playing with regexps than in really solving the problem, but may I interest you in an alternate way, a fun way in its own right, where the parsing has already been done. A way that might even work reliably?

Look for modules that work on the parsed version, in the B:: namespace, such as B::Deparse.

And of course Hook::LexWrap will probably just do what you want...

  • Comment on Re: parsing code, finding block boundaries