in reply to Re: Creating hash with variables
in thread Creating hash with variables
#!/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'
|
|---|