|Perl: the Markov chain saw|
2D table in perlby sirok4 (Initiate)
|on Oct 27, 2012 at 10:04 UTC||Need Help??|
sirok4 has asked for the
wisdom of the Perl Monks concerning the following question:
Suppose I have this file with 2 lines: e.g
And I want to create this table with Perl:
where the 1st row is the range of number that comes after 'C' and the 1st column is the range of number comes after 'H'.So the script should check each word in the input, and put it's amount (2nd line in input file) inside the correct cell.
For example: in C5H30 i have 5 after 'C' and 30 after 'H' and its amount is 5. so, i should put 5 in cell (21-30,3-5)Another example: I have amount of 10 in cell (1-10,1-2) because i have two such names that fit into these ranges of C and H and their total amount sums to 10 (1+9)
I'm new to Perl and its data structures, and I'm not sure how to do it but know Perl definitely can do it.
Can anyone share his thoughts ? Thanks