On 14 Nov 01 at 10:48:43PM, Michael G Schwern wrote:
> Schuyler's got it down to:
>
> perl -ne
>'(/^\\s*[^#]|^\\s*#\\s*(include|define|(ifn?|un)def|else|elif|endif)/)&&print'
>
> and
>
> perl -ne
>'$s||=/^#!.*perl/i;$s&&(/^\\s*[^#]|^\\s*#\\s*(include|define|(ifn?|un)def|else|elif|endif)/)&&print'
The keyword part of the regex:
(include|define|(ifn?|un)def|else|elif|endif)
seems to have lost the plain "if" case along the way.
(include|define|if|ifdef|ifndef|else|elif|undef|endif)
^^
You can substitute (untested):
((ifn?|un)def|(el|end)?if|define|include|else)
which is nearly the same length, but includes "if", and beats the
closest correct alternative so far:
(include|define|if(n?def)?|el(se|if)|undef|endif)
by 3 characters.
Regards,
Ian