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

34 lines
749 B
Perl
Raw Normal View History

package DDG::Goodie::Reverse;
# ABSTRACT: Reverse the order of chars in the remainder
use strict;
use DDG::Goodie;
triggers startend => "reverse text";
zci answer_type => "reverse";
2014-10-09 07:22:41 -07:00
zci is_cached => 1;
handle remainder => sub {
2016-05-18 13:05:35 -07:00
my $in = $_;
return if $in eq ""; # Guard against empty query.
2016-05-18 13:05:35 -07:00
#Filter out requests for DNA/RNA reverse complements, handled
# by the ReverseComplement goodie
return if $in =~ /^complement\s(of )?[ATCGURYKMSWBVDHN\s-]+$/i;
my $out = reverse $in;
return qq|Reversed "$_": | . $out, structured_answer => {
data => {
title => $out,
subtitle => "Reverse string: $in"
2016-05-18 13:05:35 -07:00
},
templates => {
group => 'text'
}
2014-10-09 07:22:41 -07:00
};
};
1;