Rob Dixon schreef: > use strict; > use warnings; > > my %pwm; > > while (<DATA>) { > my $col = 0; > foreach my $c (/\S/g) { > $pwm{$c}[$col++]++; > } > } > > foreach my $freq (values %pwm) { > $_ = $_ ? $_ / keys %pwm : 0 foreach @$freq; > } > > use Data::Dumper; > print Dumper \%pwm; > > > __END__ > AAA > ATG > TTT > GTC
Is "keys %pwm" the right divisor, or is the number of lines? Variant: #!/usr/bin/perl use warnings ; use strict ; my ($c, $r, %pwm) ; /\s/ ? ($r++, $c=0) : $pwm{$_}[$c++]++ for do {local $/; <DATA> =~ /(.)/sg} ; for (values %pwm) { ($_||=0)/=$r for @$_ } ; use Data::Dumper ; print Dumper \%pwm ; __DATA__ AAA ATG TTT GTC :) -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>