|
|
Bobby wrote:
>
> I'm passing @nums values from an html form; so now my @nums = ($list) where
> $list = 97000,97005,98000,96100,94003 . The rand funtion now interprets $list
> as a string and not integers so the script doesn't works anymore. How do i
> convert values with that list from a string to itegers so that the script
> will work properly? Thanks for any suggestion.
Please take not of John Krahn's response, which I believe is superior to the
others in this thread. The program below does what you ask.
HTH,
Rob
use strict;
use warnings;
use List::Util 'shuffle';
use constant WINNERS => 4;
my $list = '97000,97005,98000,96100,94003';
my @winners = (shuffle $list =~ /\d+/g)[0..WINNERS - 1];
print "@winners\n";
|
|