Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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. 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... this is all in my head... Oh, boy...

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://137042]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2017-08-21 05:47 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (317 votes). Check out past polls.