Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

random numbers?

Status
Not open for further replies.

elegidito

Programmer
Jan 19, 2002
358
im looking for a function to generate random numbers, for example Javascript has Math.random() im looking for a similar function in CGI. thanks Suceess, thats the way you spell success!
Got a question? Ask IMOZRMY!
 
Code:
$lower=1000; 
$upper=2000000; 
$random = int(rand( $upper-$lower+1 ) ) + $lower; 
print $random,"\n";
---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
thanks so much. -- i was also wondering how you can access the variables passed to the page in the location (javascript has document.location.search... any help wud b appreciated Suceess, thats the way you spell success!
Got a question? Ask IMOZRMY!
 
Code:
<form action=&quot;wee.cgi&quot; method=&quot;post&quot;>
<input name=&quot;theinput&quot; value=&quot;2&quot; ....
...

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
 ($name, $value) = split(/=/, $pair);
 $value =~ tr/+/ /;
 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;
 $value =~ s/<!--(.|\n)*-->//g;
 $FORM{$name} = $value;
}

if ($FORM{theinput} == 2) {
 # 'theinput' value is 2 do something
}
hope this help ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top