in reply to Re: Golf: Files Containing a Pattern
in thread Golf: Files Containing a Pattern

Changing your 2nd grep to a map saves 1.
#234567890123456789012345678901234 grep{open F,$_;map/$_[0]/,<F>}<*>
--
Pug

Replies are listed 'Best First'.
Re^3: Golf: Files Containing a Pattern
by tadman (Prior) on Oct 19, 2002 at 08:50 UTC
    Getting a little crazy can save three more strokes:
    grep{open _,$_;map/@_/,<_>}<*>
    Not much wiggle room left, I think.
      Untested, but should work in theory ...
      grep{open _;map/@_/,<_>}<*>
      And that's another three off.

      _________
      broquaint

        I had no idea that my attempt at obfuscation would actually lead to something, as I was just using underscore as a variable name to amuse myself. From open:
        If EXPR is omitted, the scalar variable of the same name as the FILEHANDLE contains the filename. (Note that lexical variables--those declared with "my"--will not work for this purpose; so if you're using "my", specify EXPR in your call to open.) See the perlopentut manpage for a kinder, gentler explanation of opening files.