SPUG: Shouldn't this work?

Todd Wells toddw at wrq.com
Thu Nov 29 15:00:08 CST 2001


It will work if you do this:
 
my $aref = [qw(one two three four)]; 
 
 
-----Original Message-----
From: Martin, Asa [mailto:asa.martin at attws.com]
Sent: Thursday, November 29, 2001 12:15 PM
To: 'spug-list at pm.org'
Subject: SPUG: Shouldn't this work?



Am I missing something, or shouldn't this syntax be valid to create a
reference to an anonymous array: 

$ cat /tmp/a 
#!/usr/bin/perl -w 
use strict; 

my $aref = qw[one two three four]; 

if (ref($aref) eq 'ARRAY') { 
   print "yes\n"; 
} 

Useless use of a constant in void context at /tmp/a line 4. 
Useless use of a constant in void context at /tmp/a line 4. 
Useless use of a constant in void context at /tmp/a line 4. 

To get it to work, I have to use: 

my $aref = ['one', 'two', 'three', 'four']; 

Then the script prints yes. 

Anyone care to enlighten me on what's happening? 

Thanks, 

Asa Martin 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/spug-list/attachments/20011129/26b4daee/attachment.htm


More information about the spug-list mailing list