|
ActivePerl
This chapter describes:
- How to install ActivePerl v5.6.1 on a Windows 2000 system.
- How to run Perl programs with ActivePerl.
Installing ActivePerl v5.6.1
1. Go to http://www.activestate.com/Products/ActivePerl/, and click the download button.
2. Download the ActivePerl 5.6.1 build 631, Windows MSI.
3. Double click on the downloaded file name: ActivePerl-5.6.1.635-MSWin32-x86.msi, and
follow the installation tool to install ActivePerl to your system at \perl.
4. Open a command window, and type in perl. If you see the following output,
your installation is ok.
>perl -v
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 631 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 17:16:22 Jan 2 2002
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
source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to
the Internet, point your browser at http://www.perl.com/, the Perl Home
Page.
Running ActivePerl
There are many ways to run ActivePerl:
1. Run the "perl" command with the Perl program included in the command line.
For example, enter the following command line in a command window:
>perl -e "print 'Hello world!';"
Hello world!
Another example:
>perl -e "for ($i=0; $i<10; $i++) {print \"$i\n\";}"
0
1
2
3
4
5
6
7
8
9
This is a cool way to run a Perl program quickly. But you can only run programs
that are small enough to fit into one command line.
Also note that double quote (") is used to put the entire program code as one
command line parameter. Any double quote inside the program needs to be protected
as (\").
2. Run the "perl" command with the Perl program supplied from the standard input
steam.
For example, enter "perl" in a command window.
Then enter the program source code followed by Control-Z, which is the End Of File
(EOF) indicator:
>perl
$s=0;
for ($i=0; $i<10; $i++) {
$s+=$i;
}
print "$s\n";
^Z
45
Obviously, you can enter a much longer program in this way. But the program is not
save permanently.
3. Run the "perl" command with the Perl program supplied in a file.
For example, enter the following program in a file called hello.prg:
print "Hello world!\n";
Then enter the following command in a command window:
>perl hello.prg
Hello world!
This is how you normally run Perl programs.
4. Run Perl program files as commands. You can do this, only if you insert
a special line at the e
You can do this, only if you name your
Perl program files with ".pl" as file name extension, because ".pl" has been
associated with the "perl" command during the installation.
For example, enter the following program in a file called hello.pl:
print "Hello world!\n";
Then enter the following command in a command window:
>hello.pl
Hello world!
It works!
|