Solved

random numbers generators

Posted on 1998-11-17
8
225 Views
Last Modified: 2010-03-04
Where can I find a script in Perl that generate random numbers for a web page?

Thanks
0
Comment
Question by:wirefram
  • 4
  • 3
8 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1206332
print rand;
0
 

Author Comment

by:wirefram
ID: 1206333
Can you be a little bit more specific? I type "print rand;" where? I don't need a script or something?

0
 
LVL 2

Accepted Solution

by:
ventolin earned 20 total points
ID: 1206334
Here is a simple cgi that will print out a random number....

-Philip

______________cut here______________>
#/usr/bin/perl

# simple cgi for experts exchange

# Require Libraries.
use CGI qw(:standard);
use CGI::Carp 'fatalsToBrowser';
$CGI::POST_MAX=1024 * 100; # max 100k posts
$CGI::DISABLE_UPLOADS = 1; # no uploads

# Start the HTML
print header("-expires"=>'now');
print start_html("-title"=>'Philip s Random Number',
                "-author"=>'philip',
                "-dtd"=>'-//W3C//DTD HTML 3.2//EN',
                "-BGCOLOR"=>'#ffffff');

# init random with time or current PID
srand(time|$$);
# where it stops nobody knows... but it will be a random num from 0 to 1000
my $value = rand (1000);
# tell the browser this value
print $value;

# end the document
print end_html;

# end the script
__END__

yo adrienne!!!!



0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:wirefram
ID: 1206335
Thanks
0
 

Author Comment

by:wirefram
ID: 2355013
How can I close the question and give my points?
0
 
LVL 2

Expert Comment

by:ventolin
ID: 2357560
you already did.
0
 

Author Comment

by:wirefram
ID: 2357621
what do I have to do so my previous Q don't show any longer with <pack> next to it?

How long will they stay there? One is 6 months old!
0
 
LVL 2

Expert Comment

by:ventolin
ID: 2357634
you'll want to ask someone who runs this service (which isn't me):

http://www.experts-exchange.com/Customer_Service/Experts_Exchange/
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question