SPUG: Shouldn't this work?
C.J. Collier
cjcollier at sinclair.net
Thu Nov 29 15:22:07 CST 2001
Heya Asa,
You'll want to put square brackets around your qw(). qw can use quite
a few delimiters, in this case, the [] act just like :: would, so if
you'd like, you can use
my $aref = [ qw[one two three four] ];
and get the desired effect.
Hope this helps,
C.J.
On Thu, 29 Nov 2001, Martin, Asa wrote:
> 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
>
>
>
>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
More information about the spug-list
mailing list