On Sat, Mar 15, 2008 at 06:09:40PM -0700, [EMAIL PROTECTED] wrote: > @@ -1367,9 +1367,10 @@ > If you need to force inner context to scalar, we now have convenient > single-character context specifiers such as + for numbers and ~ for strings: > > + $x = g(); # scalar context and g() > @x[f()] = g(); # list context for f() and g() > @x[f()] = +g(); # list context for f(), scalar context for g() > - @x[+f()] = g(); # scalar context for f() and g() > + @x[+f()] = g(); # scalar context for f(), list context for g() > # -- see S03 for "SIMPLE" lvalues > > @x[f()] = @y[g()]; # list context for f() and g() > @@ -1377,6 +1378,18 @@ > @x[+f()] = @y[g()]; # scalar context for f(), list context for g() > @x[f()] = @y[+g()]; # list context for f(), scalar context for g() > > +Sigils used as list prefix operators may also be used to force context: > + > + @x = $ g(); # scalar context for g() > + $x = @ g(); # list context for g() > + $x = % g(); # list context for g() (and coercion to hash)
Given the last paragraph, wouldn't the earlier example be more correctly described as @x[f()] = +g(); # list context for f(), number context for g() and more general example instead be @x[f()] = $ g(); # list context for f(), scalar context for g() given that the "obvious" hash analogy of @x[+f()] = g(); # scalar context for f(), list context for g() is %x{+f()} = g(); # number context for f(), list context for g() and (if I understand context and its coercion correctly) actually that's probably not what the novice wanted. In that what they probably wanted was %x{~f()} = g(); # string context for f(), list context for g() So instead of emphasising + and ~, it feels to me that that is less to remember (and less to teach) if the examples were prominent in their use of (generic) scalar context: %x{$ f()} = g(); # scalar context for f(), list context for g() Nicholas Clark