|
bnbform.cgi
This is it, the script itself, and the only other file that needs to be edited. Remember
to edit the copy in the CGI directory of your drive, not the original one.
The first line you will see is
#!/usr/bin/perl
which is the path to the Perl interpreter. This is fine as it is at Spaceports, so
remember that for future reference. An acceptable variation is
#!/usr/local/bin/perl
so if a script has that as the first line, that is also okay at Spaceports. Anything else
as a first line will not work. Other hosts may have a different path to Perl, but those two
are the most commonly used.
Path to Perl?
You need to know the path to Perl because the script needs to know it. Perl is the program
that sits on the Web server. These text files we are adapting are Perl scripts. The
script doesn't do the processing, the Perl interpreter does. The script is basically a bridge
between the HTML code and the Perl on the server. Try thinking of your script as the
instructions and Perl as the part that actually does the hard work. (I could insert some
analogy about husbands and wives here, but I know better than that!)
Without a path, the script doesn't know where Perl is on the system, and it can't stop and ask
for directions. The path is like a map or signpost that lets your script know how to find the
Perl engine that drives it. Without that it can't complete the tasks you are asking of
it.
The next line
Now we have that straight, we can continue...
Immediately under the path to Perl, insert the following code:-
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
This will make any errors in the script show in your browser. Without it, you will just
see the Spaceports main page if something isn't right. Perl is not very informative about
errors, especially when invoked through a browser - it was really designed for use at the UNIX
command line prompt. Most users won't have that luxury(?) unless they install the Perl
interpreter on their own system for testing.
Tic-Tac-Toe?
You might be wondering what all those # symbols are about. Well, they mark the
line as a comment - everything after them on that line is ignored by the Perl interpreter.
They are there to help us mere humans understand what the code is supposed to be doing.
That's why there are so many!
The more thoughtful among you might now be wondering how come the path to Perl thing works if it
has a Perl comment symbol in front of it. The answer is it isn't a Perl command at all - it's
a UNIX command. There would be no point telling Perl where Perl is after all.
|