fixed counter, only returns string if input contains chars a-z

master
unlisted 2012-05-07 10:58:54 -04:00
parent d7d68f3d1a
commit 45d8bfc2f8
1 changed files with 12 additions and 7 deletions

View File

@ -9,16 +9,21 @@ handle remainder => sub {
if ($_)
{
my %freq;
my @chars = split //, "\L$_";
my $lower = lc;
my @chars = split //,$lower;
foreach my $char (@chars)
foreach (@chars)
{
++$freq{$char} unless $_ eq ' ';
++$freq{$_} if $_ =~ /[a-z]/i;
};
return "FREQUENCY: " . keys %freq if $_;
my @out;
foreach my $key (keys %freq)
{
push @out, (join ":",$key,$freq{$key});
print "$freq{$key}\n";
};
return "FREQUENCY: " . join ' ',sort(@out) if @out;
};
return;