2014-06-14 05:40:31 -07:00
|
|
|
package DDG::Goodie::Reverse;
|
|
|
|
# ABSTRACT: Reverse the order of chars in the remainder
|
|
|
|
|
2015-02-22 12:09:29 -08:00
|
|
|
use strict;
|
2014-06-14 05:40:31 -07:00
|
|
|
use DDG::Goodie;
|
|
|
|
|
2014-07-04 07:43:19 -07:00
|
|
|
triggers startend => "reverse text";
|
2014-06-14 05:40:31 -07:00
|
|
|
|
|
|
|
zci answer_type => "reverse";
|
2014-10-09 07:22:41 -07:00
|
|
|
zci is_cached => 1;
|
2014-06-14 05:40:31 -07:00
|
|
|
|
2014-06-04 00:49:20 -07:00
|
|
|
handle remainder => sub {
|
2016-05-18 13:05:35 -07:00
|
|
|
my $in = $_;
|
|
|
|
|
2016-05-19 05:14:08 -07:00
|
|
|
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
|
|
|
};
|
2014-06-04 00:49:20 -07:00
|
|
|
};
|
2014-06-14 05:40:31 -07:00
|
|
|
|
|
|
|
1;
|