node1 node2 weight status 23 34 -897 1 24 46 -10 0 #### use BerkeleyDB; use MLDBM qw(BerkeleyDB::Hash Storable); my %hash; my @seqRelation; $hash{'key'} = \@seqRelation; my $dbFile = '/tmp/relation.db'; tie %hash, 'MLDBM', -Filename => $dbFile, -Flags => DB_CREATE or die $!; # read into the file content my $inFile = shift; open(IN,"zcat $inFile | ") or die "Can not open $inFile:$!"; while() { chomp; my @fields = split "\t"; my ($seq1,$seq2,$w,$s) = @fields; push @{$seqRelation[$seq1]}, join(',', $seq2, $w, $s); # also store it in the other direction push @{$seqRelation[$seq2]}, join(',', $seq1, $w, $s); } ......