develooper Front page | perl.perl5.porters | Postings from February 2001

map refuses quoted key in hash creation

Thread Next
From:
H . Merijn Brand
Date:
February 26, 2001 10:45
Subject:
map refuses quoted key in hash creation
Message ID:
20010226181702.1677.H.M.BRAND@hccnet.nl
Why does map allow unquoted left side of => op in return pair, but not a quoted
equivalent?

l1:/tmp > cat test.pl
#!/pro/bin/perl -w

use strict;

my %hash = (
    ( map {  $_  => "" } qw(key1 key2) ),
    ( map {  $_  => 0  } qw(key3 key4) ),
    ( map { "$_" => "" } qw(key5 key6) ),
    ( map { "$_" => 0  } qw(key7 key8) ),
    );
l1:/tmp 110 > perl5.7.0 test.pl
syntax error at test.pl line 8, near "} qw(key5 key6)"
Execution of test.pl aborted due to compilation errors.
l1:/tmp 111 > perl5.6.1 test.pl
syntax error at test.pl line 8, near "} qw(key5 key6)"
Execution of test.pl aborted due to compilation errors.
l1:/tmp 112 > perl5.6.0 test.pl
syntax error at test.pl line 8, near "} qw(key5 key6)"
Execution of test.pl aborted due to compilation errors.
l1:/tmp 113 > perl5.00503 test.pl
syntax error at test.pl line 8, near "} qw(key5 key6)"
Execution of test.pl aborted due to compilation errors.
l1:/tmp 114 >

-- 
H.Merijn Brand           Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)
using perl-5.005.03, 5.6.0, 5.6.1, 5.7.1 & 623 on HP-UX 10.20 & 11.00, AIX 4.2
   AIX 4.3, WinNT 4, Win2K pro & WinCE 2.11 often with Tk800.022 &/| DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About