<div class="gmail_quote">On Sun, Oct 11, 2009 at 9:09 AM, Shlomi Fish <span dir="ltr"><<a href="mailto:shlomif@iglu.org.il">shlomif@iglu.org.il</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Sunday 11 Oct 2009 04:53:28 Quantum Mechanic wrote:</div></blockquote><div>[snip] <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">> The awk in question looked like this:<br>
> : awk is much better than perl at one-line summations:<br>
> > : awk '{t += $1} END {print t}'<br>
><br>
> Which was followed up by this:<br>
> : With perl you can say<br>
> :<br>
> > : perl -ane '$t += $F[0]'<br>
> > : but you have no way of tacking on an END clause.<br>
><br>
> Now, that was a long time ago, so it may have been true then. But certainly<br>
> not anymore, and not for a long time:<br>
><br>
> perl -lane '$t += $F[0] }{ print $t'<br>
><br>
<br>
</div>Heh nice. Golf put aside, you can still use an explicit END {... } clause in a<br>
-p or -n program.<br></blockquote><div><br>Yes, that's true. I guess it bugs me that an END is inside the loop, even though it's only registered once. I guess I was also toying with the golf aspect, and the Eskimo Greeting. Probably too much obfu, when an END is much clearer:<br>
<br><div style="margin-left: 40px;">perl -lane '$t += $F[0]; END {print $t}'<br></div><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
BTW, I talked with Larry Wall on IRC and from what he recalled perl's -i flag<br>
was his innovation. Later on, the GNU people implemented a similar "-i" flag<br>
in GNU sed. The POSIX sed standard still doesn't have it:<br>
<br>
<a href="http://www.opengroup.org/onlinepubs/000095399/utilities/sed.html" target="_blank">http://www.opengroup.org/onlinepubs/000095399/utilities/sed.html</a><br>
<br>
It's possible that the sed implementations of the BSDs (FreeBSD, NetBSD,<br>
OpenBSD, etc.) have implemented a similar flag, but it may still be absent<br>
from the seds of older and or less actively maintained distributions (e.g:<br>
HP/UX , AIX , Win32's Services For Unix , maybe Solaris , etc.)<br></blockquote><div><br>Sometimes good ideas get loose, and everyone wants one. =)<br></div></div><br>-- <br>-QM<br>Quantum Mechanics: The dreams stuff is made of<br>