my %data; while (<>) { my ($id1, $id2, $int) = split; $data{$id1}{$id2} = $int; }