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

22 lines
378 B
Perl
Raw Normal View History

2012-02-29 15:21:49 -08:00
package DDG::Goodie::Xor;
use DDG::Goodie;
triggers any => 'xor', '⊕';
zci is_cached => 1;
2012-03-20 21:08:12 -07:00
zci answer_type => "xor";
2012-02-29 15:21:49 -08:00
handle query_raw => sub {
my @nums = grep(!/(xor|⊕)/, split(/\s+(⊕|xor)\s+/i, $_));
my $num = 0;
foreach (@nums) {
2012-03-08 10:48:56 -08:00
$num ^= ord(chr($_)) if /^\d+$/;
return unless /^\d+$/;
2012-02-29 15:21:49 -08:00
}
return "$num" if $num;
return;
2012-04-15 08:04:36 -07:00
};
1;