Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: looking for a perl way to build a hash

by code-ninja (Scribe)
on Jul 26, 2013 at 19:07 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2016-09-30 14:02 GMT
Find Nodes?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:

    Results (569 votes). Check out past polls.