On Sat, Feb 6, 2010 at 2:05 AM, Lyle <[email protected]> wrote:
> Alex Francis wrote:
>> $ perl -e 'use strict; use warnings; sub foo { return ( 6, 7 ) } my
>> $got = foo(); print $got . "\n"'
>> 7
>>
>> $ perl -e 'use strict; use warnings; sub foo { my @ret = ( 6, 7 );
>> return @ret } my $got = foo(); print $got . "\n"'
>> 2
>>
>
> Surely there is a way of forcing list context without creating an array?
Not really. You can use the "baby-cart-operator" @{[ ]} to save typing:
perl -Mstrict -Mwarnings -E 'sub foo { return @{[ 6,7 ]} }; say
scalar(foo()); say foo()'
2
67
Mark.
_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm