%one; %tow; while () { chomp(my @line = split/\s+/); push @{$one{$r[0]}}, [ @line[1..$#r] ]; push @{$tow{$r[1]}}, [ @line[2..$#r] ]; }