Moving files

Erik Price eprice at ptc.com
Mon Jan 6 12:22:34 EST 2003


Derek Martin wrote:

>>This particular one-liner is very readable when properly indented and 
>>code-formatted, making use of few of the esoteric symbols that make 
>>reading Perl scripts hard.  I like it quite a bit.
> 
> 
> I disagree, in large part, though I've definitely seen worse. I find
> the syntax of the grep and map to be pretty cryptic, and as a result
> the purpose of them is obscure to anyone who isn't familiar with the
> Perl syntax used.  The version I wrote is much less so, IMO.

Agreed that your version is more straightforward, probably even more 
elegant (who am I to decide), but does not your script require the 
reader to know what the "s///" operator does, or what shift() does?  In 
other words, assuming that the reader of the script does know how to 
read Perl including the standard-library functions "grep" and "map", 
then the script is perfectly readable, even using temporary variables 
such as "@f" and "$n" rather than taking the obvious Perl shortcuts of 
omitting them and implying the value (something that I think only Perl 
lets you get away with).

A question for you -- do you find

   doSomething if (condition);

to be less readable than

   if (condition) {
     doSomething;
   }

?  For someone who has even only a few hours' experience with Perl, the 
former is generally more readable in a larger script with more lines. 
Of course, by itself in an email it's hard to convey how nice it is to 
see a one-line if statement.

Just my opinions...


Erik

PS: FWIW, Python is a friendlier and IMO superior language for writing 
scripts where legibility is important, but you can't write a oneliner 
like the OP's Perl script using Python.  I think a lot of Perl users 
like the way that it is quick to write.




More information about the gnhlug-discuss mailing list