HTML Goodies: PERL Primer, Part 1
...use these to jump around or read it all
[What Is PERL?]
PERL is a little different. You need to have access to a server that has granted you permission to use PERL. Some will tell you, as I have been told many times, you can get your own copy of PERL at http://www.perl.com/ (under Downloads) and install it on your own computer. I've never done that so I wouldn't ask that you do it. I am going to teach you using the same methods I used to learn the language. I tested all of my files online, so that's the way I'll suggest you do it. If you want to install PERL on your system, more power to you. If it's successful, let me know.
I write and edit my PERL scripts in the same text editor I use to write my HTML: Notepad. I suggest you also use Notepad. You may use an assistant program to edit your HTML document. If so, you DO NOT want to edit your PERL scripts in that assistant. HTML assistant programs are known for adding code and altering your work without telling you. These PERL scripts must be saved as text only, with nothing more than what you wrote to the page. Notepad is the way to go.
Now that you have the tools on your end, let's talk about the server end.
What You Need
- You will need an account with an Internet Service Provider (ISP) that will allow you access to PERL. I have only ever worked with UNIX servers when dealing with PERL, so these primers will also follow that format. Yes, PERL is available on NT servers now, but the methods of using it there are different than what I will discuss here. If I were to make a strong suggestion, I would suggest finding a UNIX server.
NT servers will most likely be running something called Active PERL. The program adds the PERL path to the system path. Again, you'll need to check with your system administrator to get a handle on all of the specifics. I've never used PERL on any system other than UNIX. I can't imagine that PERL on NT is overly hard, but you'll need to get the scoop on that from your server people rather than me.
- The server should allow you the ability to change file and directory (CGI-BIN) permission. This will explained in Primer Two. How you set your permissions is up to you. I set all of mine by Telnetting into the server and doing it by hand. You may want to use an FTP program. Ask your ISP the best way to set your permissions on their system. I will discuss settings modification here through Telnet. If your ISP wants you to set permissions through an FTP program, let me know and I'll post a link to it here.
I have been on three different servers that would not allow me to create a CGI-BIN for my PERL scripts. They had to create it for me. Past that, I was allowed to post scripts into that directory. If that's the case, be happy. They saved you a step.
- PERL is not big on popping up error messages when the script fails to run, so you need to ask your ISP to allow you access to their PERL error log. This will make your life a great deal easier when the script won't run. The only problem I've run into, in terms of error logs, is that you get to see everyone else's errors. The last three servers I've used showed all errors, listing them as they came in. You may have to sort through the list if the server is busy and people have a lot of bad scripts running. I'm on that server right now!
- You need to find out your server's path to PERL. The traditional path is:
In fact, that's the path I'll use when you get the scripts in these primers. Every server I've been on has followed this path. Your ISP may be different. The easiest way to find your server's path is to Telnet into your account and, at the prompt, type in:
The path will be returned. Yes, I know it's easier to simply ask the person selling you the ISP account, but he or she is busy. You can find that path yourself. ;-)
Once you have all of the above, which you may already have, we can get started.
Why A Path?
You need to know the path to PERL because the scripts that you create needs to know it. PERL is the program that sits on the server. The pages you'll write are PERL scripts. You see, it's not your script that does the work, it's PERL. Your script is simply a bridge between the HTML and the PERL on the server. Think of your script as the instructions, but it's PERL that actually does the work.
Without that path, the script doesn't know where PERL is located. It can't complete the functions you're asking it to complete. That path connects your script to the engine that drives it. That's why you need a path.
What Is PERL?
Practical Extraction and Report Language. You sharp-eyed readers may now be wondering why it's spelled "PERL" rather than "PEARL". It's because when the language came out, there already was a "PEARL". (You knew it was going to be a scary scientific answer, didn't you?)
PERL was almost named "GLORIA", after the wife of the man who invented it, Larry Wall. Wall was given the task of creating a program that would allow interaction and control between computers on both U.S. coasts. He started with a program he had written earlier, rm, and bulked it up to perform all the functions he needed to control 12 computers. PERL was the result.
And now you're going to start learning it yourself. Primer Two will get you into your server, create a CGI-BIN, and start you on your way to setting file permissions. After the next primer, you'll actually know what I mean when I tell you to chmod to 775.
Won't that impress your friends?
[What Is PERL?]