Learning perl

Learning perl

This book is not intended as a comprehensive guide to Perl; on the contrary, in order to keep the book
from growing unmanageably large, we've been selective about covering only those constructs and issues
that you're most likely to use early in your Perl programming career

Foreword Next:
Preface
Foreword
Contents:
Second Edition Update
Attention, class! Attention! Thank you.
Greetings, aspiring magicians. I hope your summer vacations were enjoyable, if too short. Allow me to
be the first to welcome you to the College of Wizardry and, more particularly, to this introductory class
in the Magic of Perl. I am not your regular instructor, but Professor Schwartz was unavoidably delayed,
and has asked me, as the creator of Perl, to step in today and give a few introductory remarks.
Let's see now. Where to begin? How many of you are taking this course as freshmen? I see. Hmmm, I've
seen worse in my days. Occasionally. Very occasionally.
Eh? That was a joke. Really! Ah well. No sense of humor, these freshmen.
Well now, what shall I talk about? There are, of course, any number of things I could talk about. I could
take the egotistical approach and talk about myself, elucidating all those quirks of genetics and
upbringing that brought me to the place of creating Perl, as well as making a fool of myself in general.
That might be entertaining, at least to me.
Or I could talk instead about Professor Schwartz, without whose ongoing efforts the world of Perl would
be much impoverished, up to and including the fact that this course of instruction wouldn't exist.
That might be enlightening, though I have the feeling you'll know more of Professor Schwartz by the end
of this course than I do.
Or, putting aside all this personal puffery, I could simply talk about Perl itself, which is, after all, the
subject of this course.
Or is it? Hmmm... .
When the curriculum committee discussed this course, it reached the conclusion that this class isn't so
much about Perl as it is about you! This shouldn't be too surprising, because Perl is itself also about you -
at least in the abstract. Perl was created for someone like you, by someone like you, with the
collaboration of many other someones like you. The Magic of Perl was sewn together, stitch by stitch
and swatch by swatch, around the rather peculiar shape of your psyche. If you think Perl is a bit odd,

perhaps that's why.
Some computer scientists (the reductionists, in particular) would like to deny it, but people have
funny-shaped minds. Mental geography is not linear, and cannot be mapped onto a flat surface without
severe distortion. But for the last score years or so, computer reductionists have been first bowing down
at the Temple of Orthogonality, then rising up to preach their ideas of ascetic rectitude to any who would
listen.
Their fervent but misguided desire was simply to squash your mind to fit their mindset, to smush your
patterns of thought into some sort of hyperdimensional flatland. It's a joyless existence, being smushed.
Nevertheless, your native common sense has shown through in spots. You and your conceptual ancestors
have transcended the dreary landscape to compose many lovely computer incantations. (Some of which,
at times, actually did what you wanted them to.) The most blessed of these incantations were canonized
as Standards, because they managed to tap into something mystical and magical, performing the miracle
of Doing What You Expect.
What nobody noticed in all the excitement was that the computer reductionists were still busily trying to
smush your minds flat, albeit on a slightly higher plane of existence. The decree, therefore, went out (I'm
sure you've heard of it) that computer incantations were only allowed to perform one miracle apiece. "Do
one thing and do it well" was the rallying cry, and with one stroke, shell programmers were condemned
to a life of muttering and counting beads on strings (which in these latter days have come to be known as
pipelines).
This was when I made my small contribution to saving the world. I was rolling some of those very beads
around in my fingers one day and pondering the hopelessness (and haplessness) of my existence, when it
occurred to me that it might be interesting to melt down some of those mystical beads and see what
would happen to their Magic if I made a single, slightly larger bead out of them. So I fired up the old
Bunsen burner, picked out some of my favorite beads, and let them melt together however they would.
And lo! the new Magic was more powerful than the sum of its parts and parcels.
That's odd, thought I. Why should it be that the Sedulous Bead of Regular Expressions, when bonded
together with the Shellacious Bead of Gnostic Interpolation, and the Awkward Bead of Simple Data
Typology, should produce more Magic, pound for pound, than they do when strung out on strings? I said
to myself, could it be that the beads can exchange power with each other because they no longer have to
commune with each other through that skinny little string? Could the pipeline be holding back the flow
of information, much as wine doth resist flowing through the neck of Doctor von Neumann's famous
bottle?
This demanded (of me) more scrutiny (of it).
So I melted that larger bead together with a few more of my favorite beads, and the same thing happened,
only more so. It was practically a combinatorial explosion of potential incantations: the Basic Bead of
Output Formats and the Lispery Bead of Dynamic Scoping bonded themselves with the C-rationalized
Bead of Operators Galore, and together they put forth a brilliant pulse of power that spread to thousands
of machines throughout the entire civilized world. That message cost the Net hundreds if not thousands
of dollars to send everywhere. Obviously I was either onto something, or on something.
I then gathered my courage about me and showed my new magical bead to some of you, and you then

began to give me your favorite beads to add in as well. The Magic grew yet more powerful, as yet more
synergy was imbued in the silly thing. It was as if the Computational Elementals summoned by each
bead were cooperating on your behalf to solve your problems for you. Why the sudden peace on earth
and good will toward mentality? Perhaps it was because the beads were your favorite beads? Perhaps it
was because I'm just a good bead picker?
Perhaps I just got lucky.
Whatever, the magical bead eventually grew into this rather odd-looking Amulet you see before you
today. See it glitter, almost like a pearl.
That was another joke. Really! I assure you! Ah well. I was a freshman once too... The Amulet isn't
exactly beautiful though; in fact, up close it still looks like a bunch of beads melted together. Well, all
right, I admit it. It's downright ugly. But never mind that. It's the Magic that counts. Speaking of Magic,
look who just walked in the door! My good buddy Merlyn, er, I should say, Professor Schwartz, is here
just in the nick of time to begin telling you how to perform miracles with this little Amulet, if you're
willing to learn the proper mysterious incantations. And you're in good hands; I must admit that there's
no one better at muttering mysterious incantations than Professor Schwartz. Eh, Merlyn?
Anyway, to sum up. What you'll need most is courage. It is not an easy path that you've set your foot
upon. You're learning a new language: a language full of strange runes and ancient chants, some easy and
some difficult, many of which sound familiar, and some of which don't. You may be tempted to become
discouraged and quit. But think you upon this: consider how long it took you to learn your own native
tongue. Was it worth it? I think so. And have you finished learning it? I think not. Then do not expect to
learn all the mysteries of Perl in a moment, as though you were consuming a mere peanut, or an olive.
Rather, think of it as though you were consuming, say, a banana. Consider how this works. You do not
wait to enjoy the banana until after you have eaten the whole thing. No, of course not. You enjoy each
bite as you take it. And each bite motivates you to take the next bite, and the next.
So then, speaking now of the fruit of Merlyn's labors, I would urge you to enjoy this, um, course. The
fruit course, of course. Ahem, that was a joke too. Ah well.
Here then, Professor, I present to you your new class. They seem to have no sense of humor whatsoever,
but I expect you'll manage somehow.
Class, I present to you Professor Randal L. Schwartz, Doctor of Syntax, Wizard at Large, and of course,
Just Another Perl Hacker. He has my blessings, just as you have my blessings. May you Learn Perl. May
you do Good Magic with Perl. And above all, may you have Lots of Fun with Perl. So be it!
So do it!
Larry Wall
September, 1993
Second Edition Update
You too, Tom.
Larry Wall

Previous: Second Edition Preface Next: Retrieving Exercises
Update
Preface
Contents:
What This Book Is About
Retrieving Exercises
Additional Resources
How to Get Perl
Conventions Used in This Book
Support
Acknowledgments for the First Edition
Acknowledgments for the Second Edition
We'd Like to Hear from You
What This Book Is About
Among other things, this book is about 260 pages long. It is also a gentle introduction to Perl. By the
time you've gone through this book, you'll have touched on the majority of the simpler operations and
common language idioms found in most Perl programs.
This book is not intended as a comprehensive guide to Perl; on the contrary, in order to keep the book
from growing unmanageably large, we've been selective about covering only those constructs and issues
that you're most likely to use early in your Perl programming career.
As a prelude to your more advanced study, however, we've included a heavier chapter at the end of the
book. It's about CGI programming, but along the way, it touches upon library modules, references, and
object-oriented programming in Perl. We hope it whets your appetite for these more advanced topics.
Each chapter ends with a series of exercises designed to help you practice what you have just read. If you
read at a typical pace and do all the exercises, you should be able to get through each chapter in about
two to three hours, or about 30 to 40 hours for the entire book.
This book is meant to be a companion volume to the classic Programming Perl, Second Edition, by Larry
Wall, Randal L. Schwartz, and Tom Christiansen, published by O'Reilly & Associates, the complete
reference book on the language.

Initially designed as a glue language under the UNIX operating system, Perl now runs virtually
everywhere, including MS-DOS, VMS, OS/2, Plan 9, Macintosh, and any variety of Windows you care
to mention. It is one of the most portable programming languages available today. With the exception of
those few sections related to UNIX systems administration, the vast majority of this book is applicable to
any platform Perl runs on.
Previous: Second Edition Learning Next: Retrieving Exercises
Update Perl
Second Edition Update Book Retrieving Exercises
Index
[ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl
Programming | Perl Cookbook ]

Previous: What This Book Is Preface Next: Additional Resources
About
Retrieving Exercises
The exercises in this book are available electronically in a number of ways: by FTP, FTPMAIL, BITFTP, and UUCP.
The cheapest, fastest, and easiest ways are listed first. If you read from the top down, the first one that works is probably
the best. Use FTP if you are directly on the Internet. Use FTPMAIL if you are not on the Internet but can send and
receive electronic mail to Internet sites. Use BITFTP if you send electronic mail via BITNET. Use UUCP if none of the
above works.
Note: The exercises were prepared using a UNIX system. If you are running UNIX, you can use them without
modification. If you are running on another platform, you may need to modify these exercises slightly. For example,
whereas under UNIX every line ends with a line-feed character (the carriage return is implicit), under DOS every line
must end with explicit line-feed and carriage-return characters. Depending upon your own configuration and transfer
method, you may need to append carriage returns. See the README file accompanying the exercises for additional
information.
FTP
To use FTP, you need a machine with direct access to the Internet. A sample session is shown below.
% ftp ftp.oreilly.com
Connected to ftp.uu.net.
220 ftp.oreilly.com FTP server (Version 6.34 Thu Oct 22 14:32:01 EDT 1992) ready.
Name (ftp.oreilly.com:username): anonymous
331 Guest login ok, send e-mail address as password.
Password: username@hostname Use your username and host here
230 Guest login ok, access restrictions apply.
ftp> cd /published/oreilly/nutshell/learning_perl2
250 CWD command successful.
ftp> get README
200 PORT command successful.
150 Opening ASCII mode data connection for README (xxxx bytes).
226 Transfer complete.
local: README remote: README
xxxx bytes received in xxx seconds (xxx Kbytes/s)
ftp> binary
200 Type set to I.
ftp> get examples.tar.gz
200 PORT command successful.
150 Opening BINARY mode data connection for examples.tar.gz (xxxx bytes).
226 Transfer complete. local: exercises remote: exercises
xxxx bytes received in xxx seconds (xxx Kbytes/s)
ftp> quit
221 Goodbye.
%

FTPMAIL
FTPMAIL is a mail server available to anyone who can send electronic mail to and receive it from Internet sites. This
includes any company or service provider that allows email connections to the Internet. Here's how you do it.
You send mail to ftpmail@online.oreilly.com. In the message body, give the FTP commands you want to run. The server
will run anonymous FTP for you and mail the files back to you. To get a complete help file, send a message with no
subject and the single word "help" in the body. The following is an example of a UNIX mail session that gets the
examples. This command sends you a listing of the files in the selected directory and the requested example files. The
listing is useful if there's a later version of the examples you're interested in.
% mail ftpmail@online.oreilly.com
Subject:
reply-to username@hostname Where you want files mailed
open
cd /published/oreilly/nutshell/learning_perl2
dir
get README
mode binary
uuencode
get examples.tar.gz
quit
.
A signature at the end of the message is acceptable as long as it appears after "quit."
BITFTP
BITFTP is a mail server for BITNET users. You send it electronic mail messages requesting files, and it sends you back
the files by electronic mail. BITFTP currently serves only users who send it mail from nodes that are directly on
BITNET, EARN, or NetNorth. BITFTP is a public service of Princeton University. Here's how it works.
To use BITFTP, send mail containing your FTP commands to BITFTP@PUCC. For a complete help file, send HELP as
the message body.
The following is the message body you should send to BITFTP:
FTP ftp.oreilly.com NETDATA
USER anonymous
PASS your Internet e-mail address (not your BITNET address)
CD /published/oreilly/nutshell/perl/learning_perl2
DIR
GET README
GET examples.tar.gz
QUIT
Questions about BITFTP can be directed to MAINT@PUCC on BITNET.
UUCP
If you or your company has an account with UUNET, you will have a system with a direct UUCP connection to
UUNET. Find that system, and type (as one line):
uucp uunet\!~/published/oreilly/nutshell/learning_perl2/examples.tar.gz
yourhost\!~/yourname/

The backslashes can be omitted if you use the Bourne shell (sh) instead of csh. The example file should appear some
time later (up to a day or more) in the directory /usr/spool /uucppublic / yourname.
Previous: What This Book Is Learning Next: Additional Resources
About Perl
What This Book Is About Book Additional Resources
Index
[ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl
Cookbook ]

Previous: Retrieving Preface Next: How to
Exercises Get Perl
Additional Resources
Perl Manpages
The online documentation for Perl, called manpages due to their UNIX origin, has been divided into
separate sections so you can easily find what you are looking for without wading through hundreds of
pages of text. Since the top-level manpage is simply called perl, the UNIX command man perl should
take you to it.[1] That page in turn directs you to more specific pages. For example, man perlre displays
the manpage for Perl's regular expressions. The perldoc command may work when the man (1) command
won't, especially on module documentation that your system administrator may not have felt comfortable
installing with the ordinary manpages. On the other hand, your system administrator may have installed
the Perl documentation in hypertext markup language (HTML) format, especially on systems other than
UNIX. If all else fails, you can always retrieve the Perl documentation from CPAN; look for this
information in Section 0.5, "How to Get Perl"."
[1] If you still get a humongous page when you do that, you're probably picking up the
ancient Release 4 manpage. You may need to change your MANPATH environment
variable.
Here are the principal manpages included with the 5.004 distribution of Perl:
Manpage Topic
perl Overview of documentation
perldelta Changes since previous version
perlfaq Frequently asked questions
perldata Data structures
perlsyn Syntax
perlop Operators and precedence
perlre Regular expressions
perlrun Execution and options
perlfunc Built-in functions

Usenet Newsgroups
The Perl newsgroups are a great, if sometimes cluttered, source of information about Perl.
comp.lang.perl.announce is a moderated, low-traffic newsgroup for Perl-related announcements. These
often deal with new version releases, bug fixes, new extensions and modules, and Frequently Asked
Questions (FAQs).
The high-traffic comp.lang.perl.misc group discusses everything from technical issues to Perl philosophy
to Perl games and Perl poetry. Like Perl itself, comp.lang.perl.misc is meant to be useful, and no question
is too silly to ask.[2]
[2] Of course, some questions are too silly to answer, especially those already answered in
the FAQ.
The comp.lang.perl.tk group discusses how to use the popular Tk toolkit from Perl. The
comp.lang.perl.modules group is about the development and use of Perl modules, which are the best way
to get reusable code. There may be other comp.lang.perl.whatever newsgroups by the time you read this;
look around.
One other newsgroup you might want to check out, at least if you're doing CGI programming on the
Web, is comp.infosystems.www.authoring.cgi. While it isn't strictly speaking a Perl group, most of the
programs discussed there are written in Perl. It's the right place to go for web-related Perl issues.
The Perl Home Page
If you have access to the World Wide Web, visit the Perl home page at http://www.perl.com/perl/. It tells
what's new in the Perl world, and contains source code and ports, documentation, third-party modules,
the Perl bugs database, mailing list information, and more. This site also provides the CPAN multiplexer,
described later.
Frequently Asked Questions List
The Perl Frequently Asked Questions (FAQ) is a collection of questions and answers that often show up
on comp.lang.perl.misc. In many respects it's a companion to the available books, explaining concepts
that people may not have understood and maintaining up-to-date information about such things as the
latest release level and the best place to get the Perl source.
The FAQ is periodically posted to comp.lang.perl.announce, and can also be found on the Web at
http://www.perl.com/perl/faq.
Since the 5.004 release of Perl, the FAQ has been included with the standard distribution's
documentation. Here are the main sections, each available as its own manpage:
perlfaq
Structural overview of the FAQ.
perlfaq1

Very general, high-level information about Perl.
perlfaq2
Where to find source and documentation to Perl, support and training, and related matters.
perlfaq3
Programmer tools and programming support.
perlfaq4
Manipulating numbers, dates, strings, arrays, hashes, and miscellaneous data issues.
perlfaq5
I/O and the "f " issues: filehandles, flushing, formats, and footers.
perlfaq6
Pattern matching and regular expressions.
perlfaq7
General Perl language issues that don't clearly fit into any of the other sections.
perlfaq8
Interprocess communication (IPC), control over the user-interface: keyboard, screen, and pointing
devices.
perlfaq9
Networking, the Internet, and a few on the Web.
Bug Reports
In the unlikely event that you should encounter a bug that's in Perl proper and not just in your own
program, you should try to reduce it to a minimal test case and then report it with the perlbug program
that comes with Perl.
The Perl Distribution
Perl is distributed under either of two licenses (your choice). The first is the standard GNU Copyleft,
which means, briefly, that if you can execute Perl on your system, you should have access to the full
source of Perl for no additional charge. Alternately, Perl may also be distributed under the Artistic
License, which some people find less threatening than the Copyleft (especially lawyers).
Within the Perl distribution, you will find some example programs in the eg / directory. You may also
find other tidbits. Poke around in there on some rainy afternoon. Study the Perl source (if you're a C
hacker with a masochistic streak). Look at the test suite. See how Configure determines whether you
have the mkdir (2) system call. Figure out how Perl does dynamic loading of C modules. Or whatever
else suits your fancy.

Other Books
Programming Perl is the definitive reference book on Perl, whereas this book is more of a tutorial. If you
want to learn more about Perl's regular expressions, we suggest Mastering Regular Expressions, by
Jeffrey E.F. Friedl (also published by O'Reilly & Associates).
Also check out O'Reilly and Associates' CGI Programming on the World Wide Web by Shishir
Gundavaram; Web Client Programming with Perl by Clinton Wong; and HTML: The Definitive Guide,
Second Edition, by Chuck Musciano and Bill Kennedy.
The AWK Programming Language, by Aho, Kernighan, and Weinberger (published by
Addison-Wesley), and sed & awk, by Dale Dougherty (published by O'Reilly & Associates), provide an
essential background in such things as associative arrays, regular expressions, and the general world view
that gave rise to Perl. They also contain many examples that can be translated into Perl by the
awk-to-perl translator, a2p, or by the sed-to-perl translator, s2p. These translators won't produce
idiomatic Perl, of course, but if you can't figure out how to imitate one of those examples in Perl, the
translator output will give you a good place to start.
For webmasters, we recommend the second edition of How to Setup and Maintain a Web Site, by
Lincoln Stein, M.D., Ph.D. (published by Addison-Wesley). Dr. Stein, renowned author of Perl's CGI.pm
module (described in Chapter 19, CGI Programming), delivers a professional and comprehensive
treatment of all issues related to administering a web site on UNIX, Mac, and Windows platforms.
We also recommend Johan Vromans's convenient and thorough quick reference booklet, called Perl 5
Desktop Reference, published by O'Reilly & Associates.
Previous: Retrieving Learning Next: How to
Exercises Perl Get Perl
Retrieving Exercises Book How to Get Perl
Index
[ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl
Programming | Perl Cookbook ]

Previous: Additional Preface Next: Conventions Used in
Resources This Book
How to Get Perl
The main distribution point for Perl is the Comprehensive Perl Archive Network, or CPAN. This archive contains not only
the source code, but also just about everything you could ever want that's Perl-related. CPAN is mirrored by dozens of sites
all over the world, as well as a few down under. The main site is ftp.funet.fi (128.214.248.6). You can find a more local
CPAN site by getting the file /pub/languages/perl/CPAN/MIRRORS from ftp.funet.fi. Or you can use your web browser to
access the CPAN multiplex service at www.perl.com. Whenever you ask this web server for a file starting with /CPAN/, it
connects you to a CPAN site, which it chooses by looking at your domain name. Here are some popular universal resource
locators (URLs) out of CPAN:
http://www.perl.com/CPAN/
http://www.perl.com/CPAN/README.html
http://www.perl.com/CPAN/modules/
http://www.perl.com/CPAN/ports/
http://www.perl.com/CPAN/doc/
http://www.perl.com/CPAN/src/latest.tar.gz
The CPAN multiplex service tries to connect you to a local, fast machine on a large bandwidth hub. This doesn't always
work, however, because domain names may not reflect network connections. For example, you might have a hostname
ending in .se, but you may actually be better connected to North America than to Sweden. If so, you can use the following
URL to choose your own site:
http://www.perl.com/CPAN
Note the absence of a slash at the end of the URL. When you omit the trailing slash, the CPAN multiplexer presents a menu
of CPAN mirrors from which you can select a site. So long as your web browser supports cookies, the CPAN multiplexer
will automatically remember your choice next time.
The following machines should have the Perl source code plus a copy of the CPAN mirror list - both available via
anonymous FTP. (Try to use the machine names rather than the numbers, since the numbers may change.)
ftp.perl.com 199.45.129.30
ftp.cs.colorado.edu 128.138.243.20
ftp.funet.fi 128.214.248.6
ftp.cs.ruu.nl 131.211.80.17
The location of the top directory of the CPAN mirror differs on these machines, so look around once you get there. It's often
something like /pub/perl/CPAN.

Where the Files Are
Under the main CPAN directory, you'll see at least the following subdirectories:
authors
This directory contains numerous subdirectories, one for each contributor of software. For example, if you wanted to
find Lincoln Stein's great CGI.pm module, and you knew for a fact that he wrote it, you could look in
authors/Lincoln_Stein. If you didn't know he wrote it, you could look in the modules directory explained below.
doc
A directory containing all manner of Perl documentation. This includes all official documentation (manpages) in
several formats (such as ASCII text, HTML, PostScript, and Perl's native POD format), plus the FAQs and interesting
supplementary documents.
modules
This directory contains unbundled modules written in C, Perl, or both. Extensions allow you to emulate or access the
functionality of other software, such as Tk graphical facilities, the UNIX curses library, and math libraries. They also
give you a way to interact with databases (Oracle, Sybase, etc.), and to manage HTML files and CGI scripts.
ports
This directory contains the source code and/or binaries for Perl ports to operating systems not directly supported in
the standard distribution. These ports are the individual efforts of their respective authors, and may not all function
precisely as described in this book.
scripts
A collection of diverse scripts from all over the world. If you need to find out how to do something, or if you just
want to see how other people write programs, check this out. The subdirectory nutshell contains the examples from
this book. (You can also find these sources at the O'Reilly & Associates ftp.ora.com site, in
/published/oreilly/nutshell/learning_perl2/.
src
Within this directory you will find the source for the standard Perl distribution. The current production release is
always in the file that is called src/latest.tar.gz.[3] This large file contains full source and documentation for Perl.
Configuration and installation should be relatively straightforward on UNIX and UNIX-like systems, as well as VMS
and OS/2. Starting with Version 5.004, Perl also builds on 32-bit Windows systems.
[3] The trailing .tar.gz means that it's in the standard Internet format of a GNU-zipped, tar archive.
Using Anonymous FTP
In the event you've never used anonymous FTP, here is a quick primer in the form of a sample session with comments. Text
in bold typewriter font is what you should type; comments are in italics. The % represents your prompt, and should not be
typed.
% ftp ftp.CPAN.org (ftp.CPAN.org is not a real site)
Connected to ftp.CPAN.org.
220 CPAN FTP server (Version wu-2.4(1) Fri Dec 1 00:00:00 EST 1995) ready.
Name (ftp.CPAN.org:CPAN): anonymous
331 Guest login ok, send your complete e-mail address as password.
Password: camel@nutshell.com (Use your username and host here)
230 Guest login ok, access restrictions apply.
ftp> cd pub/perl/CPAN/src 250 CWD command successful.
ftp> binary (You must specify binary transfer for compressed files) 200 Type set to
I.
ftp> get latest.tar.gz

200 PORT command successful.
150 Opening BINARY mode data connection for FILE.
226 Transfer complete.
.
. (repeat this step for each file you want)
.
ftp> quit 221 Goodbye.
%
Once you have the files, first unzip and untar them, and then configure, build, and install Perl:
% gunzip < latest.tar.gz | tar xvf -
% cd perl5.003 (Use actual directory name)
Now either one of these next two lines:
% sh configure (Lowercase "c" for automatic configuration)
% sh Configure (Capital "C" for manual configuration)
% make (Build all of Perl)
% make test (Make sure it works)
% make install (You should be the superuser for this)
Fetching modules
For retrieving and building unbundled Perl modules, the process is slightly different. Let's say you want to build and install
a module named CoolMod. You'd first fetch it via ftp (1), or you could use your web browser to access the module service
from http://www.perl.com/, which always retrieves the most up-to-date version of a particular registered module. The
address to feed your browser would be similar to:
http://www.perl.com/cgi-bin/cpan_mod?module=CoolMod
Once you've gotten the file, do this:
% gunzip < CoolMod-2.34.tar.gz | tar xvf -
% cd CoolMod-2.34
% perl Makefile.PL (Creates the real Makefile)
% make (Build the whole module)
% make test (Make sure it works)
% make install (Probably should be the superuser)
When the CoolMod module has been successfully installed (it is automatically placed in your system's Perl library path),
your programs can say:
use CoolMod;
and you should be able to run man CoolMod (or maybe perldoc CoolMod ) to read the module's documentation.
Previous: Additional Learning Next: Conventions Used in
Resources Perl This Book
Additional Resources Book Conventions Used in This
Index Book
[ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook
]