Re: In these times of economic crisis...
Phil Carmody <[email protected]> Sun, 26 Apr 2009 11:08:13 +0000 (GMT)
| Newsgroups | gmane.comp.lang.perl.golf |
|---|---|
| Message-ID | <[email protected]> |
--- On Sun, 4/26/09, robert wilson <[email protected]> wrote: > Phil Carmody wrote: > > We need dollar-free golf! > > > > In order to answer the question "what ratio of words > in the SOWPODS wordlist share no letters in common with the > word mackerel?", I quickly threw this together: > > > > perl -ne '$c[m/[mackrel]/]++;}print($c[1]/$.,$/);{' < sowpods > > > > However, there were complaints that it had too many dollar signs. > > > > What's the shortest equivalent script which uses no dollar signs at all? > > > perl -le 'print+(grep{/[mackrel]/}@w=<>)/@w' < sowpods Wow!!! It's obvious in retrospect. It's clear my original was horrifically wasteful, and can at least be shortened to this at the cost of one dollar: perl -le 'print+(grep{/[mackrel]/}<>)/$.' < sowpods Phil