Re: qw(l i s t) vs (l, i, s, t)

Jean-Pierre Vidal <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
Le Mardi 22 Juillet 2003 01:48, Tor Hildrum a écrit :
> Not sure if this belongs here, but anyway:

[snip...]

as said Randal :

In modern versions of Perl [...] returning either
- a list in a list context,
- or the last element of a list in a scalar context.

(don't forget 'scalar @array' return the lenght of the array)

we are in scalar context, because scalar(@ARGV):

@ARGV = qw(1 2); # scalar(@ARGV) is 2 (number of elements)
scalar qw(2, 3) # is 3, last element of the list => false

@ARGV = qw(1 2); # is 2
scalar(2, 3) # is 3  => false

@ARGV = qw(1 2 3); # is 3
scalar (2, 3) # is 3  => true

@ARGV = qw(1 2 3); # 3
scalar qw(2 3) # is 3 => true

This is the result in perl 5.8 on linux

so the problem seems in the version of perl you are running, if I understand 
the answers from Yitzchak Scott-Thoennes, Jasper McCrea and Stefan Stiasny, 
and obviously Randal.

Thanks for my fwp since I have learned more about perl...
My apologies for my Frenchglish

Jean-Pierre
-- 
Jean-Pierre Vidal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.