Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Creating hash with variables

by colwellj (Monk)
on Feb 11, 2010 at 04:19 UTC ( [id://822581]=note: print w/replies, xml ) Need Help??


in reply to Re: Creating hash with variables
in thread Creating hash with variables

This works.
#!/usr/bin/perl -w use strict; my (%ipkey,$value,$key); my $count = 0; my @rawdata = ('key1','value1','key2','value2','key3','value3'); foreach (@rawdata) { if ($count == 0) { $key = $_; $count++; next; }else{ $value = $_; $ipkey{$key} = $value; $count = 0; } }<\code> <br> OUTPUT<code> DB<4> x %ipkey 0 'key2' 1 'value2' 2 'key1' 3 'value1' 4 'key3' 5 'value3'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2024-04-23 14:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found