I have pairs like this (Data sorted to %hash format(I have large data))
G1-G2
G2-G3
D1-D2
D3-D2
G3-D3
G2-D3
Perl script
use strict;
use warnings;
use Data::Dumper;
my %hash;
$hash{'G1'}='G2';
$hash{'G2'}='G3';
$hash{'D1'}='D2';
$hash{'D3'}='D2';
$hash{'G3'}='D3';
$hash{'G2'}='D3';
print Dumper \%hash;
Out put
$VAR1 = {
'G1' => 'G2',
'G2' => 'D3',
'D3' => 'D2',
'G3' => 'D3',
'D1' => 'D2'
};
Here missing G2-G3 bcz key hash duplicated
I need to add duplicates (i can use array but have large data system is going slow)
any fast method add pairs and get condition input of possible pairs
If $input=’G2’
Get output G2->(G3,D3,G1)
If $input=’D2’
Get output D2->(D1,D3)