Hi--I recently posted a message titled "writing readable Perl." In it, I
said:

--- snip ---
I am a Perl semi-nubie who has, over the years, been mystified by various
pieces of Perl code.... I'm interested in in writing some
kind of article for the Perl community advocating a common sense approach to
writing Perl code that can be read (by you and others) easily in the
future.

I have begun collecting examples of code that I feel are needlessly
complicated or obscure and invite you to send me things that you think are
examples of this sort of thing.
--- snip ---

However, I asked the wrong people for advice. I now realize that I should
have asked those of you who, like me, are newer at Perl and are often
annoyed by obscure Perl idioms and practices.

Here's an example of what I'm talking about. One programmer, wanting to
calculate the number of elements in an array, does so with the code

     @myArray + 0 

(This forces the array to be evaluated in scalar context, thus returning the
number of elements in the array.) A more direct way to accomplish the same
thing would be

     scalar(@myArray)

which makes the process used obvious to everyone, pro and novice alike.

This is a simple example--too simple for some--but it gives you an idea of
what I'm looking for. Thanks again for your time.

--greggw


### I'm using voice-recog. software to dictate e-mails,  ###
### so please ask if something reads funny; thanks <--   ###

Reply via email to