suppose u have file
File A
A -> G
C->D
A -> R
P->A
File B
A=1
C=2
D=3
E=4
F=5
G=6
H=7
I=8
K=9
L=10
M=11
N=12
P=13
Q=14
R=15
S=16
T=17
V=18
W=19
Y=20
From File A and File B
output shud be such that
In any one first one shud have -1 and second one shud have 1
So,
In the first one (A)shud have -1 and second one (G) shud have 1
so that
A -> G
1:-1 2:0 3:0 4:0 5:0
6:1 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0
similarly C have -1 and D have 1
C->D 1:0 2:0
3:-1 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0
A->R
1:-1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0
15:1 16:0 17:0 18:0 19:0 20:0
P->A P have -1 and A have 1
P->A
1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0
13:-1 14:0 15:0 16:0 17:0 18:0 19:0 20:0
- #!/usr/bin/perl
-
my %hash;
-
while(<FILEB>){
-
chomp;
-
my @tmp=split("=",$_);
-
$hash{$tmp[0]}=$tmp[1];
-
}
-
-
open $fh,"<","FILEA";
-
while(<$fh>){
-
chomp;
-
/([A-Z])\s*->\s*([A-Z])/;
-
print $_;
-
print "\n";
-
}
-
for(my $i=1;$i<=20;$i++){
-
if($i == $hash{$1}){
-
print " ",$i,":",-1;
-
}
-
elsif($i == $hash{$2}){
-
print " ",$i,":",1;
-
}
-
else{
-
print " ",$i,":",0;
-
}
-
}
-
print "\n";
-
}
-
-
But after running this perl command
the result displayed is
A->G 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0
C->D 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0
A->R 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0
P->A 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0
Whant can be possible solution?
Thanks