in reply to Entering the land of Perl
Moreover, counting characters in a string is idiomatically done via the tr operator. We know in advance that the possible characters are A, C, T and G only, so you can write:sort_and_print_hash_keys(\%letters);
Which was exactly my solution to the DNA problem on Rosalind :-)#!/usr/bin/perl use strict; use warnings; use feature qw(say); my $s = shift; say join " ", map eval "$s =~ tr/$_//", qw/A C G T/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Entering the land of Perl
by manbroski (Initiate) on Apr 04, 2013 at 21:51 UTC | |
by choroba (Cardinal) on Apr 05, 2013 at 06:06 UTC |