my $filename = "edges.txt"; #Set a variable for our file name open(my $fh, "<", $filename) or die "Can't open file $filename."; #Open the file edges.txt while (<$fh>) { if ($_ =~ m/(\S+)\t(\S+)/) { #Match the IDs in the file to $1 and $2 $edge{$1,$2}= $holder; #assign IDs as format $edge{ID1,ID2} close $fh; #Close the file edges.txt my @list = keys %uniqedge; print "@list\n"; #Prints the list of keys, but they are uni-directional (i.e. repeated for ID1-ID2 and ID2-ID1)