[tpm] Larry was only joking

Shlomi Fish shlomif at iglu.org.il
Sat Oct 17 18:03:25 PDT 2009


Hi Quantum Mechanic!

Sorry for the late-ish response.

On Sunday 11 Oct 2009 21:09:03 Quantum Mechanic wrote:
> 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}'
> 

Yeah well, this may be a colour of the bike shed argument:

* http://bikeshed.com/ (try hitting reload a few times - ;-) )

* http://en.wikipedia.org/wiki/Parkinson%27s_Law_of_Triviality

Or it's a matter of style and preference. I think the meaning of the second 
program is clearer, and it's most probably not substantially slower, because 
it only has a small overhead of compilation.

"Eskimo greeting" - heh. Reminds me of "the spaceship operator", "the Orcish 
manuever", "the goatse operator", and probably a few other things I don't 
readily recall for Perl's syntactical paradigms that some people claim is 
line-noise. I happen to think that when they are properly formatted, they 
actually provide very useful visual aids that allow to see the meaning of the 
code very quickly. See for example:

http://www.shlomifish.org/humour/fortunes/shlomif.html#scary-perl-expertise

> > 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. =)
> 

Yeah. I've been thinking that in software (and in many other fields too) you 
get credit for results, not for originality.

Regards,

	Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
First stop for Perl beginners - http://perl-begin.org/

Chuck Norris read the entire English Wikipedia in 24 hours. Twice.


More information about the toronto-pm mailing list