Solved

adding random number to input tag

Posted on 1998-10-21
2
140 Views
Last Modified: 2013-12-25
I'm using a perl cgi script which generates input tags for a form.  I'd like the value for one of the input tags to be randomly generated.
ie.

print "<TD><INPUT NAME=\"Filename\" TYPE=\"text\" SIZE=\"25\" MAXLENGTH=\"25\" value=\"I'd like a random number here\"></TD></TR>\n";

In the above Input tag, I'd like the "value" portion to be a random number of at least 8 digits.  Can someone help me? :)
0
Comment
Question by:kenneth022597
2 Comments
 

Author Comment

by:kenneth022597
Comment Utility
Edited text of question
0
 
LVL 5

Accepted Solution

by:
b2pi earned 100 total points
Comment Utility
Make sure you're using perl5.004 or later. Assuming that you want an integer:

print substr(sprintf("%.8f",rand(1.0)),2)

If you're using a perl before 5.004, add a call at the top of your program (call it only once)

srand($$ + time);


0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now