Add srand() to handle fn for Goodies using rand()

master
Zaahir Moolla 2014-07-04 18:30:29 -04:00
parent bee7bc01f3
commit 39fae8a17c
4 changed files with 11 additions and 0 deletions

View File

@ -71,6 +71,8 @@ sub shorthand_roll_output {
}
handle remainder_lc => sub {
# Ensure rand is seeded for each process
srand();
my @values = split(' and ', $_);
my $values = @values; # size of @values;
my $out = '';

View File

@ -21,6 +21,9 @@ attribution github => [ 'https://github.com/UnGround', 'Charlie Belmer' ],
web => ['http://www.charliebelmer.com','Charlie Belmer'];
handle remainder => sub {
# Ensure rand is seeded for each process
srand();
my $address = join(':', map {sprintf '%0.2X', rand(255)}(1..6));
my $text_response = "Here's a random MAC address: $address";

View File

@ -18,6 +18,9 @@ attribution github => ['http://github.com/nospampleasemam', 'nospampleasemam'],
web => ['http://dylansserver.com/', 'Dylan Lloyd'];
handle query_parts => sub {
# Ensure rand is seeded for each process
srand();
my $numericalized = str2nbr($_);
return unless $numericalized =~ /^(\d{1,50}) (letter|char|character) words?$/;

View File

@ -18,6 +18,9 @@ topics 'entertainment';
my @quotes = share('quotes.txt')->slurp;
handle query => sub {
# Ensure rand is seeded for each process
srand();
return if $_ !~ m/quotes?/;
my $rand = int(rand(scalar(@quotes)));
my $quote = $quotes[$rand];