Aldebaran has asked for the wisdom of the Perl Monks concerning the following question:
When I study a syntax, I try to use it for any odd task that turns up. We have a contest for a club of sorts where the winner gets a prize of value $25 or so, but the idea is to foster participation. Hence, we don't want perpetual winners or the winner to be the person who sits at his computer all day, so we're choosing a random correct answer as opposed to the first.
Where I'm stuck now is making a composite of the those who answer correctly less those who have already won. I looked for examples in the books I have and couldn't find one. If I were to proceed in the manner of the syntaxes I've studied before, I would loop through indices, making exhaustive comparisons. What is the perl way to remove a sublist from another list
$ perl rand1.pl 7246281254938614119473194136957146644855362901505395617562308444592359 +441659779924940736387588266118823158415004985978328481067994672839164 +223678436588869 2 $ cat rand1.pl #!/usr/bin/perl -w use strict; use feature ':5.10'; use Crypt::Random qw( makerandom ); my $r = makerandom ( Size => 512, Strength => 1 ); print "$r\n"; srand($r); my @winners=("ruth","sheila"); my @correct=("ruth","martin","dee","zack"); my @composite = @correct - @winners; print "@composite \n"; $
Thanks in advance,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: removing a sublist
by Skeeve (Parson) on Apr 20, 2012 at 22:21 UTC | |
by Aldebaran (Curate) on Apr 21, 2012 at 22:17 UTC | |
Re: removing a sublist
by eyepopslikeamosquito (Archbishop) on Apr 20, 2012 at 23:54 UTC | |
Re: removing a sublist
by toolic (Bishop) on Apr 21, 2012 at 02:00 UTC | |
Re: removing a sublist
by Riales (Hermit) on Apr 20, 2012 at 21:57 UTC | |
Re: removing a sublist
by Cristoforo (Curate) on Apr 21, 2012 at 15:28 UTC | |
Re: removing a sublist
by Kenosis (Priest) on Apr 20, 2012 at 23:08 UTC |