[tpm] Larry was only joking

Quantum Mechanic quantum.mechanic.1964 at gmail.com
Sat Oct 10 19:53:28 PDT 2009


While wasting time today, I visited the Wikiquote page for Larry
Wall<http://en.wikiquote.org/wiki/Larry_Wall>.
Among the numerous gems was this one:

Hey, I had to let awk be better at *something*...
:-)<http://groups.google.com/group/comp.lang.perl/msg/af646f4ae85fcbe4>
>

The awk in question looked like this:

: awk is much better than perl at one-line summations:
> :       awk '{t += $1} END {print t}'
>

Which was followed up by this:

: With perl you can say
> :       perl -ane '$t += $F[0]'
> : but you have no way of tacking on an END clause.
>

Now, that was a long time ago, so it may have been true then. But certainly
not anymore, and not for a long time:

perl -lane '$t += $F[0] }{ print $t'

Not that I'm trying to golf it, but that seems reasonably simple (especially
compared with the attempts in the original thread).

I first saw this idea in a Usenet post by Abigail on how to write wc in
Perl:

perl -pe '}{$_=$.'

[The '}{' seems to be called the "Eskimo Greeting".]

-- 
-QM
Quantum Mechanics: The dreams stuff is made of
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20091010/7b2a023c/attachment.html>


More information about the toronto-pm mailing list