in reply to Bug with lists?

This is actually pretty well-documented in perldata:

This interpolation combines with the facts that the opening and closing parentheses are optional (except necessary for precedence) and lists may end with an optional comma to mean that multiple commas within lists are legal syntax. The list 1,,3 is a concatenation of two lists, 1, and 3, the first of which ends with that optional comma. 1,,3 is (1,),(3) is 1,3 (And similarly for 1,,,3 is (1,),(,),3 is 1,3 and so on.) Not that we'd advise you to use this obfuscation.

If you take that logical explanation into account I think you don't want to make perl complain over two commas directly following each-other.

(However, I wonder if that documentation really is true. To me it seems like 1,,,3 "really" is ((1,),),3 is (1,),3 is 1,3. Futher, afaik the comma operator needs something to the left. In (,) it's got nothing.)

-Anomo

Replies are listed 'Best First'.
Re: Re: Bug with lists?
by TGI (Parson) on Feb 19, 2002 at 00:43 UTC

    Under Perl 5.004_02 for Windows, I get a syntax error if I try perl -e "print join(qq/\n/, (1,),(,),3  )". However, perl -e "print join(qq/\n/, ((1,),), 3 )" works as Anomo predicted. An anonymonk trumps perldoc? I never thought I'd see the day!


    TGI says moo

Re: Re: Bug with lists?
by demerphq (Chancellor) on Feb 19, 2002 at 08:58 UTC
    Hmm. I can't recall reading that. Thanks.

    While I suppose this puts it all to rest, I'd still like to see it documented under perlop. After all it seems to me that that would be the first port of call trying to track down this issue.

    Nevertheless, much thanks.

    BTW: Im guessing you are one of the perlbug recipients... Would I be correct?

    Yves / DeMerphq
    --
    When to use Prototypes?