Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: looking for a perl way to build a hash

by code-ninja (Scribe)
on Jul 26, 2013 at 19:07 UTC ( [id://1046591]=note: print w/replies, xml ) Need Help??


in reply to looking for a perl way to build a hash

Everyone has put in their ways, I'll put mine too for consideration... :)
#!/usr/bin/perl use strict; use warnings; my $str1 = "1,2,3"; my $str2 = "a,b,c"; my ($k, %hash, $i); $i = 0; my @keys = split /,/, $str1; my @values = split /,/, $str2; foreach $k (@keys){ $hash{$k} = $values[$i++]; } print %hash;

I leave it up to you to print the hash in the formatted way

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-03-28 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found