Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How to make a hash out of two arrays,one with keys and other with values?

by hnd (Scribe)
on Jun 30, 2009 at 06:29 UTC ( #775924=note: print w/replies, xml ) Need Help??


in reply to How to make a hash out of two arrays,one with keys and other with values?

mapping is the best..... since you have large arrays
use strict; my %hash=map {@array1[$_]=>@array2[$_]} 0..$#array1;
  • Comment on Re: How to make a hash out of two arrays,one with keys and other with values?
  • Download Code

Replies are listed 'Best First'.
Re^2: How to make a hash out of two arrays,one with keys and other with values?
by NetWallah (Canon) on Jun 30, 2009 at 13:27 UTC
    No - that does not work.

    You need =>     , not =

    . Also, the preferred sigil for array element in perl5 is $.

    my %hash=map {$array1[$_]=>$array2[$_]} 0..$#array1;
    (Identical to ikegami's posting.)

         Potentia vobiscum ! (Si hoc legere scis nimium eruditionis habes)

      really sorry.........
      i overlooked it.....

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://775924]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2022-01-25 00:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (65 votes). Check out past polls.

    Notices?