frequency counter plugin
This commit is contained in:
parent
586dd1c7fb
commit
d7d68f3d1a
29
lib/DDG/Goodie/Frequency.pm
Normal file
29
lib/DDG/Goodie/Frequency.pm
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package DDG::Goodie::Frequency;
|
||||||
|
# ABSTRACT: Displays frequency of each character
|
||||||
|
|
||||||
|
use DDG::Goodie;
|
||||||
|
|
||||||
|
triggers start => 'frequency';
|
||||||
|
|
||||||
|
handle remainder => sub {
|
||||||
|
if ($_)
|
||||||
|
{
|
||||||
|
my %freq;
|
||||||
|
|
||||||
|
my $lower = lc;
|
||||||
|
my @chars = split //,$lower;
|
||||||
|
|
||||||
|
foreach my $char (@chars)
|
||||||
|
{
|
||||||
|
++$freq{$char} unless $_ eq ' ';
|
||||||
|
};
|
||||||
|
|
||||||
|
return "FREQUENCY: " . keys %freq if $_;
|
||||||
|
};
|
||||||
|
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
zci is_cached => 1;
|
||||||
|
|
||||||
|
1;
|
Loading…
x
Reference in New Issue
Block a user