Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: Coding superstitions

by mrbbking (Hermit)
on Jan 08, 2002 at 06:57 UTC ( #137042=note: print w/ replies, xml ) Need Help??


in reply to Re: Coding superstitions
in thread Coding superstitions

where mstone does this...

@list = ( 'item one', 'item two', 'item three', ## <- unnecessary punctuation );
mrbbking does this...
@list = ( 'item one' ,'item two' ,'item three' );
I picked up this particular habit from some IBM Mainframe DBAs. With the comma on the same line as the thing that comes after it, I can comment out any line of the array assignment and the whole thing is still syntactically valid. I like to keep things as clean as I can.
...in my code anyhow. My office is a pig sty.

...wait a minute... if mstone can get away with an extra trailing comma, then I guess I could comment out the last line of the assigment, and the trailing comma wouldn't cause a problem...
...so this is all in my head... Oh, boy...


Comment on Re: Re: Coding superstitions
Select or Download Code
Re (tilly) 3: Coding superstitions
by tilly (Archbishop) on Jan 08, 2002 at 07:06 UTC
    The trailing comma is good. It means you don't have to worry about it if you add some new lines to the array.
Re: Re: Re: Coding superstitions
by NoobJW (Initiate) on Jan 10, 2002 at 01:44 UTC
    Unless, of course, someone decides to comment out this line:
    @list = ( # 'item one' ,'item two' ,'item three' );

    To be fair, I've never had to comment out the first line of a list in any language. Of course, since you are allowed to have trailing commas, mstone's solution allows you to truly comment out any line. This feature was probably added for this explicit purpose.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://137042]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2014-09-19 11:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (135 votes), past polls