print scalar(foo), ', ', $_, $/ for foo;
I can't get that to work in any version of Perl I have here. It doesn't print anything at all in 5.6.0, and from 5.6.1 up to bleadperl, it prints:
Use of uninitialized value in print at cl line 16. Flintstone,
: lvalue was introduced in 5.6.0, so trying older versions of Perl doesn't make sense.
However, if I change the line to
print scalar(foo), ', ', $_, $/ for my @a = foo;
I get the expected:
Flintstone, Fred Flintstone, Wilma Flintstone, Pebbles
It's the lvalue that messes up. Consider the reduced case:
my @foo = qw /one two three/; sub foo () : lvalue {@foo} print for foo; __END__ Use of uninitialized value in print at /tmp/bug line 9
But removing the ': lvalue' prints the content of the array. I'll perlbug it.
Abigail
In reply to Re: More Lvalue Subs - Double-Barreled Closures
by Abigail-II
in thread More Lvalue Subs - Double-Barreled Closures
by Zaxo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |