On Mon, Mar 26, 2007 at 05:36:08PM +0200, Abigail wrote:
> It looks like the return value is the right hand side only if there's no
> assignment done - the first time it returns an lvalue:
>
> $ curperl -E 'sub f {(state $x = 42)++; say $x} f; f;'
> 43
> Modification of a read-only value attempted at -e line 1.
So this would be a bug?
$ ./perl -Ilib -wlE 'sub foo :lvalue {state $a = 3}; print foo()++ for 1..3'
3
Can't return a readonly value from lvalue subroutine at -e line 1.
Nicholas Clark
Thread Previous
|
Thread Next