http://www.perlmonks.org?node_id=137042


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...

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.