📄 ch1.htm
字号:
<HTML>
<HEAD>
<TITLE>Chapter 1 -- An Introduction to Perl</TITLE>
<META>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#CE2910">
<H1><FONT SIZE=6 COLOR=#FF0000>Chapter 1</FONT></H1>
<H1><FONT SIZE=6 COLOR=#FF0000>An Introduction to Perl</FONT>
</H1>
<HR>
<P>
<CENTER><B><FONT SIZE=5><A NAME="CONTENTS">CONTENTS</A></FONT></B></CENTER>
<UL>
<LI><A HREF="#TheHistoryofPerl">
The History of Perl</A>
<UL>
<LI><A HREF="#ThePurposeofPerl">
The Purpose of Perl</A>
<LI><A HREF="#TheAdvantagesofPerl">
The Advantages of Perl</A>
<LI><A HREF="#LocatingPerl">
Locating Perl</A>
<LI><A HREF="#SupportforPerl">
Support for Perl</A>
</UL>
<LI><A HREF="#PerlfortheNT">
Perl for the NT</A>
<UL>
<LI><A HREF="#Hardware">
Hardware</A>
<LI><A HREF="#Software">
Software</A>
<LI><A HREF="#UnsupportedFeaturesinWindowsNTPerl">
Unsupported Features in Windows NT Perl 5.001</A>
<LI><A HREF="#TipsonInstallingPerlforWindowsNT">
Tips on Installing Perl for Windows NT</A>
<LI><A HREF="#SecurityAlert">
Security Alert</A>
</UL>
<LI><A HREF="#TheImportanceofPerl">
The Importance of Perl</A>
<UL>
<LI><A HREF="#TheDisadvantagesofPerl">
The Disadvantages of Perl</A>
<LI><A HREF="#PerlversusPerl">
Perl 4.0 versus Perl 5.001</A>
<LI><A HREF="#PerlandBeyond">
Perl 5.001 and Beyond</A>
<LI><A HREF="#GettingStartedwithPerl">
Getting Started with Perl</A>
</UL>
</UL>
<HR>
<P>
In this chapter you will be introduced to Perl and its origins
in the Unix operating system. We will explore the initial reasons
for Perl's creation as a handy systems administration tool kit.
Then, we touch on how Perl has evolved into a CGI (common gateway
interface) language that can be used with the Windows NT server.
Finally, I will cover what you will need to operate Perl on your
system, from the hardware requirements to the software necessary,
as well as the limitations Perl has. This should ready you for
getting your feet wet in the next chapter by actually learning
how Perl works.
<H2><A NAME="TheHistoryofPerl"><FONT SIZE=5 COLOR=#FF0000>
The History of Perl</FONT></A></H2>
<P>
While this book demonstrates how Perl is used to give Web pages
more depth in their interactivity, Perl wasn't created to do this.
It was originally created because someone wanted to make their
job of administering a large network a little easier. All the
programming tools available then didn't work as well as he or
she needed them to, so out popped Perl. The man who created Perl
was Larry Wall. Perl stands for Practical Extraction and Report
Language. Some time ago Larry Wall wanted to develop a better
way to create debugging reports. He was working in the UNIX operating
system trying to produce bug reports from a Usenet-new-like hierarchy
of files. He first tried the UNIX utility awk<I> </I>to do this,
but he couldn't get the results he needed. <I>Awk</I> is a common
UNIX utility that uses regular expressions to manipulate and process
text. Building on this application, Wall developed the first version
of Perl. This new tool proved handier than he had first anticipated,
so he gave copies of this new language to some other UNIX programmers.
They worked with Perl and made it perform more tasks. Wall then
developed Perl to a state where he could release it as a general
systems administrator utility for the greater UNIX world.
<P>
Interest in Perl grew, so versions of Perl for other operating
systems were developed, one of which was ported to the Windows
NT operating system. Wall has referred to Perl's development as
the melting of one magic bead after another into each other, so
that the end result contains more magic than all the beads added
together separately.
<P>
Portability can also refer to the ability of a file to move from
one operating system to another. For example, when you take an
MS Word document from a Macintosh computer to a PC you are still
able to work on the file on the new computer with little modification
necessary, making MS Word documents highly portable between operating
systems that can use MS Word.
<P>
Wall, with the help of others, has crafted Perl into five different
versions, each one improving on the previous. Perl is now available
in version 5.001 for Windows NT.
<P>
The world of Perl is now a considerable size, with the support
of a 211-page manpage (the name given to an online manual), which
can be found at <A HREF="javascript:if(confirm('http://www.perl.com/perl/info/documentation.html \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.perl.com/perl/info/documentation.html#online'" tppabs="http://www.perl.com/perl/info/documentation.html#online">http://www.perl.com/perl/info/documentation.html#online</A><B>
</B>in these formats:
<UL>
<LI>Postscript
<LI>ASCII
<LI>HTML
<LI>PDF
</UL>
<P>
In addition, there are several books devoted to Perl, and six
Perl newsgroups:<BR>
<P>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR VALIGN=TOP><TD><B>NOTE</B></TD></TR>
<TR VALIGN=TOP><TD>
<BLOCKQUOTE>
<I>Porting and portability refer to the process of taking an existing language, application, or file type that runs on one operating system and translating the source code so it can be used on another, totally different, system. Sometimes in this
translation process certain features of the original language are lost because of the limitations of the new operating system. With the different portings of Perl, some features are modified or omitted. These omissions are usually well documented, and
these unsupported features in Perl for Windows NT can be found in a table in Appendix </I>
</BLOCKQUOTE>
</TD></TR>
</TABLE></CENTER>
<P>
<UL>
<LI><I>news://comp.lang.perl.announce</I>-Devoted to new developments
and announcements concerning Perl
<LI><I>news://comp.lang.perl.misc</I>-News that deals with the
many tasks Perl can do, and how to get it to do things it hasn't
yet
<LI><I>news://comp.lang.perl.modules</I>-A discussion of Perl
module development takes place (modules being collections of Perl
programs, or scripts, that usually have a connecting theme)
<LI><I>news://comp.lang.perl.tk</I>-A highly technical newsgroup
concerning Perl/Tk, a variation on Perl which adds Tk 4 widget
toolkit capabilities to Perl, but is only currently available
for UNIX systems, so it isn't anything you should worry about
now
<LI><I>news://comp.infosystems.www.authoring.cgi</I>-Covers Perl
and its CGI functions
<LI><I>news://genetics.upenn.edu/perl.porters-gw</I>-In case you
are interested in the various programming issues related to porting
Perl
</UL>
<P>
There are many other online resources for Perl, some of which
are detailed later in this chapter.
<P>
In the beginning Perl was designed to be a data reduction language.
This means that it could steer through an assortment of files,
examine large amounts of text, call up commands to get fluid,
or dynamic, data, and output reports based on this information.
Previously, programmers have had to resort to dedicated C programs
to accomplish this. If you have ever had to program in C you will
realize that, given a choice, no one who is not a programmer at
heart wants to have to use C if they can help it. Perl speeds
up its processing time by being self-compiling, making it very
attractive to the rest of us. Perl is also compatible with C.
<P>
As more programmers used Perl it was discovered that it could
also manipulate files quite easily. It is a language that gives
the programmer the ability to deal with the files themselves,
separate from what they contain. This has made Perl very popular,
because it allows you to both change a file's contents and its
very nature with the same utility.
<P>
What makes Perl even more popular is that it is free, and very
easy to find and download for your computer. Details about where
to find Perl are covered later in this chapter.
<P>
Perl is distributed under both the GNU General Public License
and the Artistic License agreement. When you install Perl you
can choose which agreement you are going to use Perl under. Read
both carefully before you decide which fits your situation best.
A full copy of each is found in Appendix A to this book.
<P>
The world that produced Perl is like yours; it is made of information
that you need, distribute, and manage every day. It doesn't matter
that Perl originated in the UNIX world, because the problems it
was created to solve are familiar to anyone working with a network,
regardless of platform.<BR>
<P>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR VALIGN=TOP><TD><B>NOTE</B></TD></TR>
<TR VALIGN=TOP><TD>
<BLOCKQUOTE>
<I>Your computer, its network, and the Internet at large is where information is posted, traded, sold, and given away in many different formats, depending on each user's needs. All this myriad data shares one common trait: it is based on text. </I>
</BLOCKQUOTE>
<BLOCKQUOTE>
<I>When I use the word text I don't want to limit its meaning to only letters that we use to make words. This is just a small part of what text is. In this book text refers to any character, be it letter, number, or symbol, that the computer can take in,
process, and/or output. Text is the building block for each file stored in your server's memory and can be interpreted into various outputs based on the user requests.</I>
</BLOCKQUOTE>
<BLOCKQUOTE>
<I>The Common Gateway Interface (CGI) works only with text, moving it in and out of your server, making text fluency a must for any language used for CGI tasks. That language has to be one that fundamentally works with text on all levels: a language such
as Perl.</I>
</BLOCKQUOTE>
</TD></TR>
</TABLE></CENTER>
<P>
<P>
When we use the Web, each of us looks for newer and better ways
to receive and present our information. Moving away from static
Web pages, we have discovered how to use CGI specifications to
create interactive pages for our Web sites. If text is the basis
of this interactive information flow, then we need a language
that can both deal with text quickly and efficiently, and which
can also manipulate the text files themselves. Welcome to Perl.
<H3><A NAME="ThePurposeofPerl">
The Purpose of Perl</A></H3>
<P>
Originally Larry Wall wanted a powerful but simple way to output
reports. Wall was working on a bug reporting system that would
work on a hierarchy of file directories. He first tried the UNIX
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -