in reply to Re^3: Maintaining context of the caller
in thread Maintaining context of the caller

The line of code is assignment to a conditional, but the values are not either both scalar or both list values. The Camel quote explaines that that is not an acceptable thing to do.
Funny, and here I thought the error message "Assignment to both a list and a scalar" explaiend why it wasn't an acceptable thing to do.
  • Comment on Re^4: Maintaining context of the caller

Replies are listed 'Best First'.
Re^5: Maintaining context of the caller
by GrandFather (Saint) on Jul 04, 2005 at 22:03 UTC

    It does if you realise that that is what is happening in the context of a conditional. From OP's parenthetical comment it is fairly clear that this particular subtlety of Perl (and Perl has a lot of them) had escaped OP.

    I thought it worth making clear that there is no syntactic sugar that will allow OP to select a list or scalar context at run time for the call by using the conditional operator in that particular fashion.


    Perl is Huffman encoded by design.
      it is fairly clear that this particular subtlety of Perl (and Perl has a lot of them) had escaped OP

      Indeed, that's true. I included the parenthetical remark to head off any suggestions that the problem was caused by precedence. Since I had ruled that out, I obviously didn't think that was the problem, but I didn't investigate enough to find out what it was. I just assumed it was something Perl wouldn't allow. Your quoted snippet cleared up the exact reason, and I appreciate it.

Re^5: Maintaining context of the caller
by ysth (Canon) on Jul 04, 2005 at 22:13 UTC
    Funny, and here I thought the error message "Assignment to both a list and a scalar" explaiend why it wasn't an acceptable thing to do.
    No, that lets you know that it's not an acceptable thing to do. The perldiag entry explains why that's so.
      My confusion is explained and all is right with the world.