SPUG: Shouldn't this work?

Tim Maher/CONSULTIX tim at consultix-inc.com
Thu Nov 29 14:56:37 CST 2001


On Thu, Nov 29, 2001 at 12:14:44PM -0800, 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];

All that does is use the [] symbols as the delimiters
for quoting the enclosed words; you need to add the anonymous
array constructor []'s too:

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

Or, less "confusingly":
my $aref = [ qw(one two three four) ];

> 
> if (ref($aref) eq 'ARRAY') {
>    print "yes\n";
> }
> 
. . . 
> Thanks,
> 
> Asa Martin
> 
> 
> 

-Tim
*=========================================================================*
| Dr. Tim Maher, CEO, Consultix        (206) 781-UNIX/8649;  ask for FAX# |
| EMAIL: tim at consultix-inc.com         WEB: http://www.consultix-inc.com  |
| TIM MAHER: UNIX/Perl  DAMIAN CONWAY: OO Perl  COLIN MEYER: Perl CGI/DBI |
|  UPCOMING CLASSES:  "Perl Prog., plus Modules", 12/3-12/6/01, Kirkland  |
|  /etc/cotd:  find /earth -follow -name bin_laden -print | xargs rm -rf  |
*=========================================================================*

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     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