in reply to Maintaining context of the caller

From the Camel:

You can assign to the conditional operator if both the second and third arguments are legal lvalues (meaning that you can assign to them), and both are scalars or both are lists (otherwise, Perl won't know which context to supply to the right side of the assignment)


Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: Maintaining context of the caller
by BUU (Prior) on Jul 04, 2005 at 21:43 UTC
    Am I the only one confused by why this was quoted in reply to this node?

      From OP:

      I thought I could solve problem (2) with the following:

          wantarray ? @r : $r = &$code;
      But that gives me an error, Assignment to both a list and a scalar. (Again, before anyone asks: no, it's not a precedence problem. I even tried adding appropriate parentheses just to be sure.)

      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.


      Perl is Huffman encoded by design.
        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.

      Yep you probably are :-) That is the perldiag entry for the error message that the OP reported. It is not permitted to assign to a conditional operator where the the second and third arguments are of different type, as the OP has here.

      /J\

      A reply falls below the community's threshold of quality. You may see it by logging in.