Two small things:
$slurb should be replaced by $contentmy ($body) = $slurp =~ /sub\s+$name\s+{\s+(.*?(?=^}\s*$))/sm;
small copy and paste error ... it actually works here but just because the sub declaration and the my declaration of slurp are by chance in the same scope.my ($body) = $content =~ /sub\s+$name\s+{\s+(.*?(?=^}\s*$))/sm;
The 'Camel' (3rd edition, chapter 5.10.3.4 - sorry no page number, this is from the bookshelf CD) has a very witty regex to match matching parens. This might also be helpful in such cases although I prefer here the suggested B::Deparse method
[replace round parens with braces]$np = qr{ \( (?: (?> [^()]+ ) # Non-parens without backtracking | (??{ $np }) # Group with matching parens )* \) }x;
-- Hofmator
In reply to Re: (jeffa) Re: getting the body text of a sub
by Hofmator
in thread getting the body text of a sub
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |