sorting pathnames by basename

Kevin D. Clark kclark at CetaceanNetworks.com
Tue Aug 20 08:07:55 EDT 2002


"Derek D. Martin" <ddm+gnhlug at pizzashack.org> writes:

> At some point hitherto, Kevin D. Clark hath spake thusly:
> > Honestly, I wrote that one-liner more with the intent of showing you
> > how cool Perl is, not with the intent of scaring you off from Perl.
> 
> And yet the example you provided was far more suited to the latter...

In your opinion.  

In fact, my one-liner is probably the cannonical way that an
experienced Perl programmer would have solved that problem (or, at
least, pretty close).

How is strcpy() implemented in C?  Traditionally, the bulk of this
function's work is implemented by a loop that can be described as:

        while (*str1++ = *str2++) ;

Every C programmer who is worth their salt will understand immediately
what this is doing, and they won't complain that this loop is "too
busy" (etc.).  They'd probably even write code like this too, when
called upon to do so.

It is the same thing for the one-liner that I wrote:  

> I've made some effort to learn Perl, and have written more than a
> handful of programs using it, some of which were long, and some of
> which were useful (though not necessarily both).  The problem I have
> always had with Perl is twofold:
> 
> 1. Perl seems to favor supporting a variety of features with obscure,
> meaningless, two-character variables that might be clearer with flags
> or arguments to functions that make use of it.

use English;

[snip]
> 2.  The people who like to program Perl seem to have a propensity to
> prefer to write code which takes advantage of all the obscure
> features, and generally to write code which is unreadable.

<shrug>  It was a one-liner.  Take it for what it was.  IIRC, I have
posted other Perl code to this list that was quite a bit more readable.

OBTW, I could have made it a couple of characters shorter.  I was
typing kind-of fast.

> I reject the notion that it is not possible to write readable code in
> Perl.  I prefer to think that Perlheads just like it that way.  =8^)

One-liners are not representitive of the readability of Perl code.  I
hope you agree.

Regards,

--kevin
-- 
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc




More information about the gnhlug-discuss mailing list