On Wed, Nov 14, 2001 at 11:08:25PM -0500, Keith C. Ivey wrote: > Michael G Schwern <[EMAIL PROTECTED]> wrote: > > > perl -ne "$saw_bang++ if /^#!.*(perl|PERL)/; print if $saw_bang && (!/^\s*#/ || > > /^\s*#\s*(include|define|if|ifdef|ifndef|else|elif|undef|endif)/)" your_file > > How about this? > > perl -pe"$_=''if >1../^#!.*perl/i;/^\s*#\s*(include|define|if(n?def)?|el(se|if)|undef|endif)/||s/^\s*#.*//s" > > Still too long (107 characters), and I cheated on the > /^#!.*(perl|PERL)/ part -- but then I think you're already > cheating by not checking what follows the preprocessor > keywords. Anyway, the scalar range operator is the real > contribution. I'm sure further improvement is possible.
We had the same idea with the range operator. Here's what I came up with, at 99 characters: perl -ne'(1../^#!.*perl/i)|/^\s*#(?!\s*(include|define|if(n?def)?|el(se|if)|undef|endif))/||print' Ronald
