in reply to making a text file to an hash array
perl -MData::Dumper -e '$_=q[a 2 b 4,5,6 c d e 45,657,-67];@arr=split +/\s+/;do { $arr[$_]!~/\d+/ and splice(@arr,$_,0,[]) } for grep {($_%2 +)} 0 .. $#arr;(%hash)=@arr;print Dumper(\%hash)'
$VAR1 = { 'e' => '45,657,-67', 'c' => [], 'a' => '2', 'b' => '4,5,6', 'd' => [] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: making a text file to an hash array
by rovf (Priest) on Jul 14, 2010 at 14:06 UTC |