using perl to calculate frequency and multiply

Suppose u have two input files FILE A and FILE B

FILE A

AACD
ABBD
ACBC

FILE B

s/ A B C D E
A 1 -2 3 4 2
B 3 2 -1 2 1
C 2 3 1 2 3
D 3 4 -3 2 2
E 1 3 4 2 3

So in FILE A we have calculated frequency at 1st position i.e.
A will be 1
then frequency at 2nd position A is 0.3
B is 0.3 ....C is 0.3
again frequency at 3rd position for C is 0.62
for B is 0.3 ...so on.......

Then at first position is frequency of A multiplied with (second FILE B)
A B C D E
11 1-2 13 14 1*2

Similarily at 2nd position is frequency of A (0.3) multiplied with second file (AA) + frequency of B(0.3) multiplied with second file (BA) + frequency of C(0.3)multiplied with second file (CA) then again frequency of A (0.3) multiplied with second file (AB) + frequency of B(0.3) multiplied with second file (BB) + frequency of C(0.3)multiplied with second file (CB)...and similarily calculated upto C, D,E

that is
A B C D E
2nd position 0.31+ 0.3 -2 ...
..... 0.3
0.3+ + 0.3
2
..... 0.30.2 + 0.33

Therefore final output will be like
pos A B C D E
Ist 1 -2 3 4 2
2nd 1.8 0.9 ............
3rd .......so on...

Stuff like this makes our collective heads hurt. What perl code have you written so far? You should start out with something like:

open(FILEA, $ARGV[0]) || die "File A: $!"
open(FILEB, $ARGV[1]) || die "File B: $!"

while (<FILEA>) { 
   $rows_in_a[$.] = [ split('') ];
}
# $rows_in_a is now a 2D array of the elements in FileA

while (<FILEB>) { 
   $rows_in_b[$.] = [ split ]; 
}
# $rows_in_b is now a 2D array of the elements in FileB. 

Thing is, in FileB, the first row and first column are labels... do they correspond to the elements in FileA? Are they actually these letter or are they some other lablel? It's not clear. But at least at this point, you can do:

$freq_a[ $i ] = $rows_in_a[ $i ]->[ $j ] * $rows_in_b[ $i+1 ]-> [ $j+1 ];

But I have no idea what you really want.

Actually real input is File A

AACD
ABBD
ACBC

where first column is all A so frequency will be 1
second column is A B C so frequency for A B C will be 0.3 0.3 0.3
third column is frequency of C = 0.3 and B =0.6....so on

In the first column will be

frequency of A * [A] [A] = 1
frequency of A * [A] [b]= -2
frequency of A * [A] [C] = 3
frequency of A * [A] [D] =4
frequency of A * [A] [E] =2

Now as in the second column there is A,B ,C
frequency of A * [A] [A] + frequency of B * [b][A] + frequency of C* [C] [A]
frequency of A * [A] [b]+ frequency of B * [b] [b]+ frequency of C* [C]
[b]frequency of A * [A] [C] + frequency of B * [b][C] + frequency of C* [C] [C]
frequency of A * [A] [D] + frequency of B * [b][D] + frequency of C* [C] [D]
frequency of A * [A] [E] + frequency of B * [b][E] + frequency of C* [C] [E]

in the third column
frequency of B * [b][A] + frequency of C* [C] [A]
frequency of B * [b] [b]+ frequency of C* [C]
[b]frequency of B * [b][C] + frequency of C* [C] [C]
frequency of B * [b][D] + frequency of C* [C] [D]
frequency of B * [b][E] + frequency of C* [C] [E]

For calculations of [A][A] , [A] [b], [b][b],[C][C]........

We have file B
s/ A B C D E
A 1 -2 3 4 2
B 3 2 -1 2 1
C 2 3 1 2 3
D 3 4 -3 2 2
E 1 3 4 2 3

where
[A][A]=1
[A][b]=-2 ..
[C] [A] =2
so on

so final output will be like

column A B C D E
1st 1 -2 3 4 2

2nd 1.8 0.9 .. so on

There's no real need to post the clarification of the assignment at this point -- you now have the basic code idea in my first post. The rest is up to you. Good luck.