Permalink
Browse files

frequency counter plugin

  • Loading branch information...
1 parent 586dd1c commit d7d68f3d1a77d7c696d1822e8f045228d9bc4786 @unlisted committed May 6, 2012
Showing with 29 additions and 0 deletions.
  1. +29 −0 lib/DDG/Goodie/Frequency.pm
View
29 lib/DDG/Goodie/Frequency.pm
@@ -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;

0 comments on commit d7d68f3

Please sign in to comment.