While wasting time today, I visited the Wikiquote page for <a href="http://en.wikiquote.org/wiki/Larry_Wall">Larry Wall</a>. Among the numerous gems was this one:<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<a href="http://groups.google.com/group/comp.lang.perl/msg/af646f4ae85fcbe4">Hey, I had to let awk be better at *something*... :-)</a><br></blockquote><br>The awk in question looked like this:<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
<font class="fixed_width" face="Courier, Monospaced">: awk is much better than perl at one-line summations: </font><br><font class="fixed_width" face="Courier, Monospaced"> : awk '{t += $1} END {print t}' </font><br>
</blockquote><br>Which was followed up by this:<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"><font class="fixed_width" face="Courier, Monospaced">: With perl you can say </font><br>
<font class="fixed_width" face="Courier, Monospaced"> : perl -ane '$t += $F[0]' </font><br><font class="fixed_width" face="Courier, Monospaced"> : but you have no way of tacking on an END clause. </font><br>
</blockquote><br>Now, that was a long time ago, so it may have been true then. But certainly not anymore, and not for a long time:<br><br><div style="margin-left: 40px;">perl -lane '$t += $F[0] }{ print $t'<br><br>
</div>Not that I'm trying to golf it, but that seems reasonably simple (especially compared with the attempts in the original thread).<br><br>I first saw this idea in a Usenet post by Abigail on how to write wc in Perl:<br>
<br><div style="margin-left: 40px;">perl -pe '}{$_=$.'<br></div><br>[The '}{' seems to be called the "Eskimo Greeting".]<br><br>-- <br>-QM<br>Quantum Mechanics: The dreams stuff is made of<br>