📄 ch1.htm
字号:
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=244><TT><FONT FACE="Courier">comp.lang.perl</FONT></TT>
</TD><TD WIDTH=346>This is the main newsgroup about Perl.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH=244><TT><FONT FACE="Courier">comp.lang.perl.modules</FONT></TT>
</TD><TD WIDTH=346>Provides discussions of Perl modules.</TD>
</TR>
<TR VALIGN=TOP><TD WIDTH=244><TT><FONT FACE="Courier">Comp.lang.perl.tk</FONT></TT>
</TD><TD WIDTH=346>Provides discussions of Tk used with Perl.
</TD></TR>
</TABLE></CENTER>
<P>
<P>
There are, of course, Web pages related to Perl. Check the newsgroups
for announcements about these pages. Here are just a couple that
I have found as of this writing:<P>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR VALIGN=TOP><TD WIDTH=350><I>URL</I></TD><TD WIDTH=200><I>Comment</I>
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=350><TT><A HREF="http://www.perl.com/" tppabs="http://www.perl.com/">http://www.perl.com/</A></TT>
</TD><TD WIDTH=200>This is the Perl language homepage. It provides links to Perl resources.
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=350><TT><A HREF="http://www.eecs.nwu.edu/perl/perl.html" tppabs="http://www.eecs.nwu.edu/perl/perl.html">http://www.eecs.nwu.edu/perl/perl.html</A></TT>
</TD><TD WIDTH=200>NWU's Perl page.</TD></TR>
<TR VALIGN=TOP><TD WIDTH=350><TT><A HREF="http://www.yahoo.com/Computers/Languages/Perl/" tppabs="http://www.yahoo.com/Computers/Languages/Perl/">http://www.yahoo.com/Computers/Languages/Perl/</A></TT>
</TD><TD WIDTH=200>Yahoo's Perl index.</TD></TR>
<TR VALIGN=TOP><TD WIDTH=350><TT><A HREF="http://www.virtualschool.edu/mon/Perl.html" tppabs="http://www.virtualschool.edu/mon/Perl.html">http://www.virtualschool.edu/mon/Perl.html</A></TT>
</TD><TD WIDTH=200>The "middle of nowhere" Perl archive (Netscape 2.0 pages).
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=350><TT><A HREF="http://www.teleport.com/~rootbeer/perl.html" tppabs="http://www.teleport.com/~rootbeer/perl.html">http://www.teleport.com/~rootbeer/perl.html</A></TT>
</TD><TD WIDTH=200>References with a special emphasis on using Perl for Web-related programming and on learning Perl.
</TD></TR>
</TABLE></CENTER>
<P>
<P>
See appendix B for more complete information on Perl-related Web
pages.
<P>
Several lists of frequently asked questions (FAQ) are posted to
the Perl newsgroups. One of the best to start with is the Perl
Meta-FAQ, produced by Neil Bowers (<TT><FONT FACE="Courier">neilb@khoros.unm.edu</FONT></TT>).
As you would expect, this is an FAQ about FAQs. It's available
at this writing from the following sources:<P>
<CENTER>
<TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR VALIGN=TOP><TD WIDTH=87>HTML</TD><TD WIDTH=467><A HREF="http://www.khoros.unm.edu/staff/neilb/perl/metaFAQ/metaFAQ.html" tppabs="http://www.khoros.unm.edu/staff/neilb/perl/metaFAQ/metaFAQ.html">http://www.khoros.unm.edu/staff/neilb/perl/metaFAQ/metaFAQ.html</A>
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=87>PostScript</TD><TD WIDTH=467><A HREF="ftp://ftp.khoros.unm.edu/pub/perl/metaFAQ.ps" tppabs="ftp://ftp.khoros.unm.edu/pub/perl/metaFAQ.ps">ftp://ftp.khoros.unm.edu/pub/perl/metaFAQ.ps</A>
</TD></TR>
<TR VALIGN=TOP><TD WIDTH=87>ASCII</TD><TD WIDTH=467><A HREF="ftp://ftp.khoros.unm.edu/pub/perl/metaFAQ.txt" tppabs="ftp://ftp.khoros.unm.edu/pub/perl/metaFAQ.txt">ftp://ftp.khoros.unm.edu/pub/perl/metaFAQ.txt</A>
</TD></TR>
</TABLE></CENTER>
<P>
<H3><A NAME="PerlExamplesAreReadilyAvailable">Perl Examples Are
Readily Available</A></H3>
<P>
Again, because Perl is so popular as a utility language, there
are lots of examples of Perl modules out there. One of the best
sources is by file transfer protocol (FTP) from one of the Comprehensive
Perl Archive Network (CPAN) sites around the world (see appendix
B).
<H2><A NAME="WhatAretheNegativesofUsingPerl"><FONT SIZE=5 COLOR=#FF0000>What
Are the Negatives of Using Perl?</FONT></A></H2>
<P>
Perl has few negatives as a scripting language for system administration
tasks and as a language for module development. But there are
a few.
<H3><A NAME="InterpretedLanguage">Interpreted Language</A></H3>
<P>
Perl is interpreted. Therefore, it will not be as fast as compiled
languages such as C or C++. Given the speed of modern CPUs, in
all but very large or time-critical applications, this will not
make a significant difference. And in fact, the interpreted nature
of the language can reduce development time significantly by eliminating
the time needed to compile and debug versions of the program (see
the previous section "The Benefits of Using Perl").
<H3><A NAME="PerceivedasPublicDomain">Perceived as Public Domain</A>
</H3>
<P>
Perl isn't strictly in the public domain (see the license agreement
for details). But it's close enough. Many large companies have
policies against using public domain or copylefted software. In
many cases, this bias is more of a mind-set than a negative, but
it can be a detriment to using Perl (see the following section,
"Informal Support").
<P>
Because Perl is in the public domain, there is no corporation
that your company can apply leverage against to get something
done. But you do have access to the Perl source to make specific
needed changes to your environment, if required.
<H3><A NAME="InformalSupport">Informal Support</A></H3>
<P>
The support for Perl is on an informal basis through the volunteer
efforts of users worldwide. Does this mean it is bad? No, not
necessarily. In fact, the "support" given through the
Internet newsgroups is probably as good as any given by a major
corporation. But you can't <I>depend</I> on your question being
answered, at least in a timely manner. And you don't have a corporation
on which you can apply pressure to support your specific environment.
On the other hand, you <I>do</I> have access to the source code
for Perl and can look into problems yourself.
<H3><A NAME="ProtectingProprietaryCode">Protecting Proprietary
Code</A></H3>
<P>
Perl isn't compiled (although there is an effort to make it so).
Thus, if you distribute your solutions, you distribute <I>code</I>.
This can be a deterrent to producing (at least your final application)
in Perl. (See the previous discussion of the benefits of Perl,
in the section "Interpreted Languages," as a prototyping
language.)
<H3><A NAME="ConcernsAboutReliability">Concerns About Reliability</A>
</H3>
<P>
Perl, in its version 5+ incarnation, is undergoing some major
changes. Things might not work or might break later. This can
be a concern for the future of applications written for a specific
version and relying on a specific feature. On the positive side,
there are a lot of people testing each release through use. Many
of these bugs are quickly detected and ironed out.
<H3><A NAME="MaintainabilityofScripts">Maintainability of Scripts</A>
</H3>
<P>
Perl has somewhat of a reputation for being unreadable. This can
be a problem for system maintenance. However, Perl is probably
no more unreadable than any C-like language. (C itself, in my
opinion, is a very un-pretty-I won't say ugly-language; Perl suffers
from that heritage.)
<P>
Like with any other language, the maintainability of Perl relies
heavily on the willingness of the programmer to structure and
comment/document the code. Because many "quick-and-dirty"
utilities are written in Perl to get a specific job done and then
expanded to be more generally usable, much of the available source
code isn't all that pretty. (Sounds a little like the evolution
of Perl itself, doesn't it?)
<H3><A NAME="GNUCopyleftLicenseAgreement">GNU Copyleft License
Agreement</A></H3>
<P>
The GNU license under which Perl is distributed is really quite
innocuous. But, it might be a problem depending upon the type
of application you are developing. If you intend to do any of
the following, Perl is probably not the best language to use:
<UL>
<LI><FONT COLOR=#000000>Sell the application as a packaged product</FONT>
<LI><FONT COLOR=#000000>Distribute an application that includes
trade secrets</FONT>
<LI><FONT COLOR=#000000>Keep your programming techniques secret</FONT>
</UL>
<H2><A NAME="WhatCanPerlDo"><FONT SIZE=5 COLOR=#FF0000>What Can
Perl Do?</FONT></A></H2>
<P>
Perl is most commonly used to develop system administration tools.
But it has also gained enormous popularity on the Internet. Perl
can be, and is, used to develop many Internet applications and
their supporting utility applications. The following sections
describe some applications of Perl in systems administration and
on the Internet.
<H3><A NAME="UNIXSystemMaintenance">UNIX System Maintenance</A>
</H3>
<P>
As mentioned before, Perl can perform the work of several other
tools, and usually in less time. It is particularly adept at processing
the text files typically used as configuration files.
<H3><A NAME="CGIScripts">CGI Scripts</A></H3>
<P>
Perl is one of the most popular languages for creating CGI applications.
There are literally thousands of examples of dynamic CGI programming
in Perl. Perl can be used to create dynamic Web pages that can
change depending on factors such as which visitor is viewing them.
<P>
One of the most common uses of Perl on the Internet is to process
form input. Perl is especially adept at this chore because most
of that input is textual-Perl's strength.
<H3><A NAME="MailProcessing">Mail Processing</A></H3>
<P>
Another popular use of Perl is for the automated processing of
Internet e-mail. Perl scripts have been used to filter mail based
on address or content. Perl scripts have also been written to
automate mailing lists. One of the most popular of these programs
is Majordomo.
<P>
I personally have written a Perl script to automate my "What's
New?" Web page. This script processes mail messages and adds
them to my "What's New?" page. It also removes the entries
from the page after they have been there for a certain length
of time.
<H3><A NAME="AutomatingWebSiteMaintenance">Automating Web Site
Maintenance</A></H3>
<P>
Perl can be used to automate the maintenance of Web sites. Because
Web pages are little more than text files in a specific format,
Perl is particularly adept at processing them. Perl's socket capability
can also be used to contact other sites and request information
using HTTP. There has even been a Web server written in Perl.
<P>
In order to check the links on a site, a Perl program must parse
the sites pages starting with the main page, extract the URLs,
and determine whether these URLs are still active.
<H3><A NAME="AutomatingFileRetrieval">Automating File Retrieval</A>
</H3>
<P>
There are several FTP clients written in Perl. Perl can be used
to automate file retrieval via FTP. Again, this combines the socket
capability of Perl with its text-processing capability.
<H2><A NAME="IsPerlforYou"><FONT SIZE=5 COLOR=#FF0000>Is Perl
for You?</FONT></A></H2>
<P>
Only you can answer that question. The next chapters will give
you a grounding in the Perl language that may help you decide
whether you wish to use Perl for Internet programming. If you
choose not to make it your main Web programming language, then
because of its versatility, ease of use, and popularity, you may
find that it becomes your utility language for the Web, if nothing
else.
<H2><A NAME="Summary"><FONT SIZE=5 COLOR=#FF0000>Summary</FONT></A>
</H2>
<P>
Perl is a practical, easy-to-use, efficient programming language.
Add it to your toolbox and use it especially when you have tasks
that involve text processing.
<P>
Like any programming language, Perl is not the only language you
should have in your toolbox, but, when chosen for the appropriate
tasks, Perl can give you the ability to solve the problem quickly.
<P>
If you're looking for a language which is beautiful, elegant,
or minimal, Perl isn't for you. If, on the other hand, you're
looking for a tool to get things done, few languages can compare
with Perl.
<P>
<HR WIDTH="100%"></P>
<CENTER><P><A HREF="index.htm" tppabs="http://www.mcp.com/815097600/0-672/0-672-30891-6/index.htm"><IMG SRC="hb.gif" tppabs="http://www.mcp.com/815097600/0-672/0-672-30891-6/hb.gif" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="#CONTENTS"><IMG SRC="cc.gif" tppabs="http://www.mcp.com/815097600/0-672/0-672-30891-6/cc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="ch2.htm" tppabs="http://www.mcp.com/815097600/0-672/0-672-30891-6/ch2.htm"><IMG SRC="nc.gif" tppabs="http://www.mcp.com/815097600/0-672/0-672-30891-6/nc.gif" BORDER=0 HEIGHT=88 WIDTH=140></A></P></CENTER>
<P>
<HR WIDTH="100%"></P>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -