These pages will help you begin your study of |
Get your perl icons for Win 95/NT here! |
Note: The perl software is actually FREE for anyone to use!
( See the links below for download sites!
And installation
instructions.)
I made this page primarily to help PC users interested in learning
Perl, but
CGI-scripts for websites on "UNIX-type"
servers will also be discussed here.
perl
is sort of a cross between an interpreter and a compiler:
It first examines the whole text of a perl program
(.pl script) for any errors. But instead of running the commands from
the interpreter, the script is then compiled and
placed into memory before being executed. Unlike other compilers though,
this machine code is (usually) never saved as an executable file.
Two FREE digital books on perl ... download now:
(Note: They are both
"offsite")
Teach Yourself Perl 5 in 21 days.zip [542 Kb]
and
Perl - Quick Reference.zip [119 Kb]
(Note: The server these files come from has them saved with
coded spaces, so you'll see, e.g., Perl%20-%20Quick%20Reference.zip
when you save them. Just rename the files anyway you like.)
print "Press the ENTER key to exit program ..."; $pause = <STDIN>; #Like a PAUSE statement in DOS .bat files
How to Download and Install Perl |
---|
The perl software can be downloaded
from various sites which are
located all over the world. Collectively,
these sites are known as
CPAN
(the Comprehensive Perl Archive Network).
The perl software is usually stored in the archives as C-language
source code which must be compiled into an executable program for your
operating system.
But the average home PC user certainly can't be expected to own a
compiler like Borland's BC++ 5 or Microsoft's VC++ 6, and obviously doesn't
have the free but very large GNU C-compiler that most UNIX users have
access to. If, you're a PC user
without a C-compiler (or
you are running Windows 95/98 ), you
need to find an archive site that has a pre-compiled (executable)
perl interpreter for your operating system.
Which one do you want?
Actually, there are two types of
Win32 perl executables to choose from!
If you're a Microsoft® server administrator, run a Windows
NT server on your home PC, or perhaps know that your webpages run on some
kind of Microsoft® Server, then you should definitely read this page
about the ActiveState version of Perl. If you
work only with UNIX servers, but you still want to run some
quick tests of a perl program on a Win 95/NT PC at home, perhaps
you'll opt for the "standard port" described below.
I've installed and run both types of Win32-perl executables on my own
PC, and believe that the standard version (as I'm calling it) is the
quickest route for those just beginning to learn the language. However, I
must defer to the experts as to which version is the best for your
particular situation.
Note: I ended up switching to the ActiveState version years ago now, and if you have Windows ME, 2000 or NT I'd say that you should immediately start with ActiveState's version! It includes many packages for handling functions that occur only on Windows Systems.
This is the most efficient way I know
of to download and install the Windows 95 / NT
perl executable: WinZip has a check box labeled "Use folder names" in its "Extract" dialog box that must be checked. NOTE: Do not change anything after the files are created! This is only the initial step of the installation process. The final name of your perl folder will be changed when you run the install program. ( The extraction itself takes almost 5 min. on a 100MHz PC since there are over 2200 files here. Again, don't let the amount of "support files" concern you. Perl itself is actually quite easy to begin using with any of the online tutorials or introductions to the language; see the links above for a free tutorial or book.) 4) Begin the Install: Please review this summary before starting the process: Perl Install Instructions. In C:\ (or whatever your ROOT directory is), find the newly created perl5.00402-bindist04-bc folder and execute the install.bat file while at a DOS prompt. ( You may wish to review/learn how to use the features of a DOS-window in Windows at this time.) Except for ONE question (about a compiler), the rest of the install process can be summarized in one phrase: `Keep pressing the ENTER key!' The first question the install file asks is: Other questions and comments include: Where should HTML be installed? [c:\perl\html] The install then shoots out a paragraph that may be difficult to understand, but even if you do not have a web server installed on your PC, it's probably best to accept the default in the next line: The install program then summarizes what it's about to do: We're now ready to copy files. Perl will be installed in `c:\perl'. HTML documentation will be installed in `c:\perl\html'. Document URLs will begin at `/c|/perl/html'. Proceed? [y] Press the ENTER key, and take a short break ... (On my 100 MHz Pentium machine, it took just 1 minute to copy the 1,207 program and module files and only 4 more minutes to do all of the POD to HTML conversions.) Click here for a listing of the perl install program's output lines (Opens in a new window). On the last screen, the install program states (in part): " You can do this in the `Environment' tab of the `System' Control Panel..." This is true ONLY in Windows NT -- there is NO "Environment Tab" in Windows95! You must add the location of PERL.EXE to your `PATH ': If you asked for things to be installed under `c:\perl', then add " c:\perl\bin " to the " PATH= " statement in your AUTOEXEC.BAT file. (This change to your AUTOEXEC.BAT file will require you to reboot before it takes effect under Windows95.) 5) Checking and Testing your new perl installation ("Standard" or "ActiveState" versions): Quick Check: After you've rebooted your computer, open an MS-DOS Prompt (or COMMAND.COM) window. You'll probably be in the Windows folder (C:\WINDOWS>) which is just fine for this test. Type in: perl -v (and press the ENTER key). Here's what you should see: This is perl, version 5.004_02 Copyright 1987-1997, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. (Or, for those with the ActiveState version, you'll see something similar to this): This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2001, Larry Wall Binary build 629 provided by ActiveState Tool Corp. http://www.ActiveState.com Built 12:27:04 Aug 20 2001 (plus the license notes, etc.) If you see the words, Bad command or file name, instead, then type: path (press ENTER) and make sure that C:\PERL\BIN is somewhere in your PATH= statement. After correcting any errors in your AUTOEXEC.BAT file, you'll have to reboot again under Win95! (For WinNT users: change this in your SYSTEM Control Panel under the "Environment" TAB.) Test 1. At the DOS prompt, type in: perldoc ( press the ENTER key). You should see something like this: Usage: PERLDOC.bat [-h] [-v] [-t] [-u] [-m] [-l] PageName|ModuleName|ProgramName PERLDOC.bat -f PerlFunc We suggest you use "perldoc perldoc" to get aquainted with the system. (The ActiveState version adds the switches [-F] [-X] and perldoc.bat -q FAQKeywords to the functionality of perldoc.bat.) Although perldoc is a DOS batch file in the C:\perl\bin folder, most of it is written in Perl. Yes, Perl script can be embedded within DOS batch files by placing it where DOS never sees it and making a "call" to the perl executable with a number of command-line switches. [ Entering perl -x -S perldoc should produce the same exact output you saw above. DOS batch files like this one make things a lot easier for you.] (Unfortunately, perldoc.bat does not always operate as intended under Windows95/NT as far as displaying the information on your screen one page at a time! This is especially true when using the - f switch! Here's my solution to this problem for a Windows95 install: Batch file and perl script for proper paging of perldoc.bat output.) Test 2. At the DOS prompt, enter: perldoc perldoc The following is just the beginning of the documentation you'll see: NAME perldoc - Look up Perl documentation in pod format. SYNOPSIS perldoc [-h] [-v] [-t] [-u] [-m] [-l] PageName|ModuleName|ProgramName perldoc -f BuiltinFunction Remember that you must use the -f switch in order to extract information about a function from the perlfunc documentation page. Test 3: Let's run a little perl script ! Open NOTEPAD (or some other text editor) and copy the following lines into it: #!perl # A VERY simple Perl script print " \n\n Hello from The Programming Republic of Perl ! \n "; exit; Now save (or rename) the file as: test3.pl If you're running Windows95, it's best to save it as: c:\windows\test3.pl (since your MS-DOS prompt opens at C:\WINDOWS>). Although the first line, #!perl , is NOT necessary to run a perl script under Windows 95/98/NT, it is good programming practice to make your perl scripts as portable (able to run on many different systems) as possible. On many UNIX-type systems, this line is written as: #!/usr/local/bin/perl and referred to as the "she-bang" line; possibly helpful in remembering that the "bang" character (!) follows the # character. This is a special line (not a comment) that tells those systems which understand it where they can find the perl executable. Windows95/NT use the PATH statement and their Registry files (containing " file associations" ) instead. The perl executable will try to run any file you ask it to as a perl script, but it's also a good practice to use the .pl extension. Let's execute the script: Open a DOS (Command prompt) window, and enter the following at the prompt: perl test3.pl If, instead, you saw something like this: If there was some other kind of error, try running the script with the -w switch. This switch turns on "warnings" which can be VERY helpful when you start writing Perl scripts of your own! ( Under the "BUGS" section of perldoc perl, you'll find the humorous comment: "The -w switch is not mandatory" as a reminder of just how important this can be at times! ) Delete the file test3.pl when you're through using it. Test 4: Testing some perl file-functions! Most browsers can either save a file as anything you wish (Netscape), or at least as a text file (MS-IE). The following link opens a Perl script (saved as a text file) in a new window. Try saving the file directly as test4.pl in your c:\windows folder as we did above (or whichever folder is the easiest for you to access from a DOS prompt). If you must save it as a text file, then rename it to test4.pl: Standard I/O and file functions test script. (First take a few minutes to read the comment lines inside of my perl script and try to picture what the program will do.) OK, pop up your DOS window again, and execute the script by entering: perl test4.pl This script will quickly test the ability of your perl installation to create a new file, write to it, append to it, read from it and finally delete it. In the process, it also tests the standard I/O (sending data to your screen and reading data in from the keyboard). If you run the script with the -w switch, you'll see the warning: Name "main::TTEST" used only once: possible typo at test4.pl line 58. This is because I fully expect the file open function (which uses the "file handle" TTEST) to fail here. If it didn't, that would mean that there was an error in deleting ("unlinking") the temporary file! You might like to check out my: Free Windows 95/98/NT Tools page here. |