zeroclickinfo-goodies/lib/DDG/Goodie/Anagram.pm

19 lines
460 B
Perl
Raw Normal View History

2012-04-23 10:46:53 -07:00
package DDG::Goodie::Anagram;
# ABSTRACT: Take a query and spit it out randomly.
use DDG::Goodie;
use List::Util 'shuffle';
triggers start => "anagram";
handle remainder => sub {
2012-04-23 11:25:51 -07:00
my @chars = split(//, $_); #convert each character of the query to an array element
my @garbledChars = shuffle(@chars); #randomly reorder the array
my $garbledAnswer = join('',@garbledChars); #convert array to string
return $garbledAnswer;
2012-04-23 10:46:53 -07:00
};
zci is_cached => 0;
1;