use strict; use warnings; open(IN, "list.txt") or die; chomp($line = ); ($element, @abc) = split /\s+/, $line; while (chomp($line = )) { ($values, @xyz) = split /\s+/, $line; for ($i=0; $i<@xyz; $i++) { $s {$elements}{$values[$i]} = $xyz[$i]; } } close(IN);