in reply to Representing a connection matrix of graph
use Data::Dumper; my %hash; while (<>) { chomp; my ($what,$where) = split /\s+/,$_; exists $hash{$what} || $hash{$what} = []; push @{$hash{$what}},$where; } print Dumper %hash; [download]