in reply to Re: When doesn't the flip-flop operator work in all scalar contexts?
in thread Why doesn't the flip-flop operator work in all scalar contexts?

I would have sworn that next, if test wouldn't work, but it does. I can't understand why from the documentation of the comma operator, though—it seems like it should try to evaluate next, then if test (which is of course a syntax error), but that doesn't happen. Instead it seems to compile the same with or without the comma.

Replies are listed 'Best First'.
Re^3: When doesn't the flip-flop operator work in all scalar contexts?
by jethro (Monsignor) on Oct 02, 2008 at 18:56 UTC

    My take on it: The 'if' always follows a simple statement so the parser takes 'next,' as statement. Depending on context (in this case void?) this will be either a comma operator or a list with a dangling comma. It seems the comma operator also throws away dangling commas like a list:

    > perl -e ' $d= (1,2); print "$d\n";' 2 > perl -e ' $d= (1,2,); print "$d\n";' 2