my %hash; while( ){ chomp; @vars = map { s/^\s+$// } split /,/; $hash{ $vars[2] } = [ @vars[ qw/0 1 3/ ] ] if $vars[0]; }