in reply to Re: Creating a random generator
in thread Creating a random generator

esper, andreas1234567, and dwm042;

There are tiny variations between the code that you gave me. Will that make a difference? I would like to have as little white space as possible. So are all the carriage returns needed between the lines?

Now that I have the .pl file, how would I integrate this onto a web page? I do not have Perl installed on my computer at home so the only way to see it working is using on a web page.

Update 1

dwm042...On the following line, does "int" mean interger?

my $col = int(rand(scalar @colors));

To all

Can the items in the array(?) be put on seperate lines? In the actual generator I would like to create each item will be a phrase, a sentence, or a table and most will consist of a lot of html code.

Update 2

What does the qw mean on the following line? Found it in a search.

my @colors = qw(red yellow green cyan blue magenta white gray black);

Update 3

The above scripts are all causing 500 Internal Service Errors when I try to run them. I CHMOD 755'd them, was that wrong? Found the fix. I needed to add the following code.

print "content-type: text/html \n\n";

Replies are listed 'Best First'.
Re^3: Creating a random generator
by Corion (Patriarch) on Sep 07, 2007 at 08:04 UTC

    The first step will be to install Perl on your computer. If you have a machine running Microsoft Windows, download and install ActiveState Perl. If you have an Apple computer, chances are good that Perl already is installed. If you have any other brand of computer, the chance that it already has Perl installed isn't that bad either, but ask your machine administrator on how to access it.

    Then, you can test the .pl files directly by saving them from a text editor and then running them. On Windows, notepad.exe is an ugly but preinstalled editor. Word and Wordpad are unsuitable for editing programs. On the Apple products I don't know what built-in editors there are except vi and vi is an editor you want to avoid when starting out.

    So, if you have saved your Perl program as myprogram.pl, you can give it a local test run by opening a command prompt in the directory you saved the file to and typing

    perl -w myprogram.pl

    If there were any errors, Perl will tell you so. If not, look if the output matches what you expect.

    After that, you can upload the Perl file myprogram.pl to your web account, possibly into the cgi-bin directory, make it executable and then link to that.

      Corion;

      My only interest in Perl is the web application of it for this one project for my website. As the output will be a .shtml file, which I can not view locally anyway, having Perl on my computer would be redundant as my server already has it on theirs. My hard drive space is very limited as well. I have been making text/html files out of almost all of my MS Word files, since MS word files are huge in comparison. If I knew how to make a web page act like Excel, I would have almost all of my spreadsheets as web pages which would hopefully be smaller.

        Installing Perl locally is merely a convenience because it makes testing and error tracking far easier. If you are starting out with Perl I really recommend the more convenient way because debugging things remotely is more difficult by far.

        Perl can also "run" .shtml files as long as these look like Perl programs. Which are far easier debugged on the command line. But you're free to choose your own way.