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

Jasper McCrea <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Organization GuideGuide
Message-ID <[email protected]>
Tor Hildrum wrote:
> 
> Not sure if this belongs here, but anyway:
> 
> [hildrum:~] tor% perl -e '@ARGV = qw(1 2); if(scalar(@ARGV)==qw(2 3) )
> {print "yes\n"}'
> yes
> [hildrum:~] tor%
> 
> [hildrum:~] tor% perl -e '@ARGV = qw(1 2); if(scalar(@ARGV)==(2, 3) )
> {print "yes\n"}'
> [hildrum:~] tor%
> 
> &&
> 
> [hildrum:~] tor% perl -e '@ARGV = qw(1 2 3); if(scalar(@ARGV)==(2, 3) )
> {print "yes\n"}'
> yes
> [hildrum:~] tor%
> 
> [hildrum:~] tor% perl -e '@ARGV = qw(1 2 3); if(scalar(@ARGV)==qw(2 3) )
> {print "yes\n"}'
> [hildrum:~] tor%

What version of perl are you using? On 5.6.0 and 5.8.0 the first two are false
for me (as I'd expect).

Although thinking about it, qw doesn't have a comma anywhere, so why would it
use the comma operator to return the last element? That wouldn't make much
sense. Would it?

I have no idea. I don't know why I'm bothering to add my 2 pennies worth.

Jasper
-- 
Lloyd Christmas: Excuse me, miss, what's the soup du jour?
Waitress:        The Soup of the Day.
Lloyd Christmas: Mmmm...sounds good, think I'll have that.
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.