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

34 lines
770 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 => html_enc($out),
subtitle => "Reverse string: ".html_enc($in)
},
templates => {
group => 'text'
}
2014-10-09 07:22:41 -07:00
};
};
1;