Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 19 lines (15 sloc) 0.373 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
package DDG::Goodie::Xor;

use DDG::Goodie;

triggers any => 'xor', '⊕';

zci is_cached => 1;
zci answer_type => "xor";

handle query_raw => sub {
    my @nums = grep(!/(xor|⊕)/, split(/\s+(⊕|xor)\s+/i, $_));
    my $num = 0;
    foreach (@nums) {
        $num ^= ord(chr($_)) if /^\d+$/;
        return unless /^\d+$/;
    }
    return "$num" if $num;
    return;
}
Something went wrong with that request. Please try again.