Merge branch 'matt/Coinflip'

master
matt lehning 2013-01-24 17:35:27 -05:00
commit 579630308c
2 changed files with 30 additions and 0 deletions

29
lib/DDG/Goodie/Coin.pm Normal file
View File

@ -0,0 +1,29 @@
package DDG::Goodie::Coin;
use DDG::Goodie;
triggers start => 'flip', 'coin';
handle query_lc => sub {
return unless my ($a, $n) = $_ =~ /^(flip a coin|flip (\d{0,2}) coins?)$/;
my @output;
my @ht = ("heads", "tails");
my $flips = 1;
my $flip;
my $b = "flip a coin";
my $count;
if($a eq $b) {
$n = 1;
}
if($n >= 1) {
for ($count = 1; $count <= $n; $count++) {
$flip = $ht[int rand @ht];
push @output, $flip;
}
}
return join(' ', @output) if @output;
};
1;

1
query.log Normal file
View File

@ -0,0 +1 @@
DDG/Goodie/Coin.pm did not return a true value at /home/matt/perl5/lib/perl5/App/DuckPAN/Cmd.pm line 21.