[tpm] Larry was only joking

Quantum Mechanic quantum.mechanic.1964 at gmail.com
Sun Oct 11 12:09:03 PDT 2009


On Sun, Oct 11, 2009 at 9:09 AM, Shlomi Fish <shlomif at iglu.org.il> wrote:

> On Sunday 11 Oct 2009 04:53:28 Quantum Mechanic wrote:
>
[snip]

> > 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'
> >
>
> Heh nice. Golf put aside, you can still use an explicit END {... } clause
> in a
> -p or -n program.
>

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:

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

BTW, I talked with Larry Wall on IRC and from what he recalled perl's -i
> flag
> was his innovation. Later on, the GNU people implemented a similar "-i"
> flag
> in GNU sed. The POSIX sed standard still doesn't have it:
>
> http://www.opengroup.org/onlinepubs/000095399/utilities/sed.html
>
> It's possible that the sed implementations of the BSDs (FreeBSD, NetBSD,
> OpenBSD, etc.) have implemented a similar flag, but it may still be absent
> from the seds of older and or less actively maintained distributions (e.g:
> HP/UX , AIX , Win32's Services For Unix , maybe Solaris , etc.)
>

Sometimes good ideas get loose, and everyone wants one. =)

-- 
-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/20091011/661eaa9e/attachment.html>


More information about the toronto-pm mailing list