tangieb01 has asked for the wisdom of the Perl Monks concerning the following question:
I got the code to sort. But I am trying to use grep to remove the duplicate numbers.
#!/usr/bin/perl #Program name: perlscript print"Content-type: text/html\n\n"; #The HTTP header print"<HTML><HEAD><TITLE> CGI/My First Form</TITLE></HEAD>\n"; print"<BODY BGCOLOR=Blue TEXT=White>\n"; print"Processing CGI form:<p>"; $formvalues=$ENV{QUERY_STRING}; @formvalues=split("&",$formvalues); print"$formvalues[0]\n"; print "<P>"; print"$formvalues[1]\n"; print "<P>"; print"$formvalues[2]\n"; print "<P>"; @formvalues2=split("=",$formvalues[0]); $NumberOfTickets=$formvalues2[1]; @formvalues2=split("=",$formvalues[1]); $NumbersOnTickets=$formvalues2[1]; @formvalues2=split("=",$formvalues[2]); $HighestNumberOnTicket=$formvalues2[1]; print "$NumberOfTickets"; print "$NumbersOnTickets"; print "$HighestNumberOnTicket"; print "Your lottery ticket number are"; print "<P>"; for ($i_lottery=0; $i_lottery<$NumberOfTickets; $i_lottery++) { for ($i=0; $i<$NumbersOnTickets; $i++) { $lotto[$i]= int(rand($HighestNumberOnTicket)) + 1; } ($new, @lotto) >0; $new=@sorted; @sorted = sort { $a <=> $b } @lotto; print "@sorted"; print "<P>"; } print "</BODY></HTML>\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I get my code to not repeat numbers and also sort the numbers
by kejohm (Hermit) on Jun 10, 2010 at 00:49 UTC | |
|
Re: How do I get my code to not repeat numbers and also sort the numbers
by kennethk (Abbot) on Jun 09, 2010 at 23:00 UTC | |
by tangieb01 (Novice) on Jun 10, 2010 at 00:05 UTC | |
by ikegami (Patriarch) on Jun 10, 2010 at 02:02 UTC | |
by tangieb01 (Novice) on Jun 09, 2010 at 23:07 UTC | |
by kennethk (Abbot) on Jun 09, 2010 at 23:11 UTC | |
|
Re: How do I get my code to not repeat numbers and also sort the numbers
by ikegami (Patriarch) on Jun 09, 2010 at 23:42 UTC |