athomason has asked for the wisdom of the Perl Monks concerning the following question:
But for some reason, %hash is then totally empty. I tried using {leftsquarebracket}$_, 0{rightsquarebracket} instead of ($_, 0), but that only gives me an array of references (erk, I dunno how to escape square brackets :). How can I do this?my @keynames = (qw/first second third fourth/); my %hash = map ($_, 0), @keynames;
As a bonus academic question, what's the best way to do the same thing, but using another array for the initialization values (i.e. not 0)?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using map to interlace an array
by mdillon (Priest) on May 15, 2000 at 11:43 UTC | |
by athomason (Curate) on May 15, 2000 at 11:59 UTC | |
|
RE: Using map to interlace an array
by pandr (Acolyte) on May 15, 2000 at 18:13 UTC | |
|
Re: Using map to interlace an array
by chromatic (Archbishop) on May 16, 2000 at 03:47 UTC | |
|
RE: Using map to interlace an array
by turnstep (Parson) on May 15, 2000 at 19:23 UTC |