my %hash; my $key; while ($_= <$file>) { my @line= split; while (@line) { my $part= shift @line; if ($part=~/^\D/) { #does not begin with a number $key= $part; $hash{$key}=[]; } else { $hash{$key}= split /,/,$part; } } }
Untested.
Your posting would look better if you surrounded code with <code> </code> tags by the way
Updated, forgot a loop
In reply to Re: making a text file to an hash array
by jethro
in thread making a text file to an hash array
by changma_ha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |