Now that I'm back home, we're getting a bit back to normalcy. Going to stay in one of my cabins tonight (~500 metres from my main house) and do some fishing (rainbow trout today).
While I'm gone, I'm hoping the Monks can chew on a couple of regexes I've got. Essentially, it is part of my Devel::Examine::Subs distribution, and its purpose is to identify subroutine definitions/declarations within a Perl file. Due to PPI, I already know where these things are, but I'm throwing as a challenge whether these regexen could be improved on. I've tried to imagine all scenarios where a sub definition could be on a single or multi-line here.
my $single_line = qr/ sub\s+\w+\s*(?:\(.*?\)\s+)?\{\s*(?!\s*[\S]) | sub\s+\{\s*(?!\s*[\S]) /x; my $multi_line = qr/sub\s+\w+\s*(?![\S])/;
I'd love for regex experts to show me examples of sub def lines that the regexes won't catch, and fixes to them. I'm especially interested in help with fixes to catch signatures and prototypes ;)
In reply to Regex critique by stevieb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |