On 02/06/2010 02:05 AM, Lyle 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?

Well yes. By assigning to a list.

$ perl -Mstrict -Mwarnings -e 'sub foo { my @ret = (6 ,7); return @ret } 
my ($got) = foo(); print $got . "\n"'
6


hth,

Dave...
_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm

Reply via email to