in reply to Re^3: Tallying overall frequency of characters in a set of strings by position
in thread Tallying overall frequency of characters in a set of strings by position

Ah right, now I understand why it was used. When adding more entries to __DATA__ such as:

__DATA__ AABBC BAABC AABBD AACBB AACBB AACBA
It returns the error: Missing argument in printf at line 16, <DATA> line 6. I can't quite figure out how to alter the print statements at the end of the script to accommodate variable a number of entries.
  • Comment on Re^4: Tallying overall frequency of characters in a set of strings by position
  • Download Code

Replies are listed 'Best First'.
Re^5: Tallying overall frequency of characters in a set of strings by position
by Anonymous Monk on May 11, 2016 at 16:59 UTC

    Oops

    #!/usr/bin/perl # http://perlmonks.org/?node_id=1162755 use strict; use warnings; my %score; chomp(my @array = <DATA>); for my $i (1..@array) { $score{$1}[$-[0]] += 1 / @array while $array[$i - 1] =~ /(.)/g; } printf " " . "%5s " x (keys %score) . "\n", sort keys %score; for my $pos ( 1..length $array[0] ) { printf "%1d" . "%7.2f" x (keys %score) . "\n", $pos, map { $score{$_}[$pos - 1] // 0 } sort keys %score; } __DATA__ AABBC BAABC AABBD AACBB AACBB AACBA