📄 ch02_03.htm
字号:
<html><head><title>Installing Perl (Perl in a Nutshell, 2nd Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Stephen Spainhour" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly & Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="0596002416L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Perl in a Nutshell, 2nd Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Java and XSLT" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch02_02.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0" /></a></td><td align="center" valign="top" width="228" /><td align="right" valign="top" width="228"><a href="ch02_04.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0" /></a></td></tr></table></div><h2 class="sect1">2.3. Installing Perl</h2><p><a name="INDEX-42" /><a name="INDEX-43" />Most likely, your systemadministrator is responsible for installing and upgrading Perl. Butif you are the system administrator, or you want to install Perl onyour own system, sooner or later you will find yourself installing anew version of Perl.</p><a name="ch02-4-fm2xml" /><blockquote><b>TIP:</b> If you run Perl and plan on upgrading to the latest distribution, beaware that pre-5.005 Perl extensions are not compatible with 5.6 andlater. This means that you must rebuild and reinstall any dynamicallyloaded extensions you built under Perl distributions earlier than5.005. If you're building under a Unix variantthat's running Perl 5.005, choose the Configureoption for 5.005 compatibility. </p></blockquote><p>Specific installationinstructions come in the <em class="emphasis">README</em> and<em class="emphasis">INSTALL</em> files of the Perl distribution kit. Ifyou don't already have the Perl distribution, youcan download it from CPAN—the latest Unix distribution is in<em class="emphasis">stable.tar.gz</em>. The information in this sectionis an overview of the installation process. The gory details are inthe <em class="emphasis">INSTALL</em> file, which you should look atbefore starting, especially if you haven't done aninstallation before. Note that operating systems other than Unix mayhave special instructions; if so, follow those instructions insteadof what's in this section or in<em class="emphasis">INSTALL</em>. Look for a file named<em class="emphasis">README.xxx</em>, in which <em class="emphasis">xxx</em>represents your operating-system type. </p> <p>In addition toPerl itself, the standard distribution includes a set of core modulesthat are automatically installed with Perl. See <a href="ch02_04.htm#perlnut2-CHP-2-SECT-4">Section 2.4, "Getting and Installing Modules"</a> later in this chapter tolearn how to install modules that are not bundled with Perl; <a href="ch08_01.htm">Chapter 8, "Standard Modules"</a> describes the standard modules in some detail.</p><a name="perlnut2-CHP-2-SECT-3.1" /><div class="sect2"><h3 class="sect2">2.3.1. Installing on Unix</h3><p><a name="INDEX-44" />Typically, the Perl kit will be packed aseither a<em class="emphasis">tar</em><a name="INDEX-45" />file or a set of<em class="emphasis">shar</em><a name="INDEX-46" />(shell archive) scripts; in either case, the file will be in acompressed format. If you got your version of Perl directly fromCPAN, it is probably in"tar-gzipped" format;<em class="emphasis">tar</em> and<em class="emphasis">gzip</em><a name="INDEX-47" />are popular Unix data-archiving formats. In any case, onceyou've downloaded the distribution, you need touncompress and unpack it. The filename indicates the kind ofcompression that was used. A<em class="emphasis">.Z</em><a name="INDEX-48" /> extension indicates you need to<em class="emphasis">uncompress</em><a name="INDEX-49" /> the file first, while a<em class="emphasis">.gz</em><a name="INDEX-50" /> extension indicates you need to<em class="emphasis">gunzip</em> the file. You then unpack the file asappropriate, read the <em class="emphasis">README</em> and<em class="emphasis">INSTALL</em> files, and run a massive shell scriptcalled <em class="emphasis">Configure</em><a name="INDEX-51" />, which tries to figure outeverything about your system and creates the file<em class="emphasis">Config.pm</em> to store the information. After thisis done, you do a series of "makes"to find header file dependencies, to compile Perl (and<em class="emphasis">a2p</em>, which translates <em class="emphasis">awk</em>scripts to Perl), to run regression tests, and to install Perl inyour system directories.</p><p>If you opt to build your own Perl under Win32, you will find that thePerl source kit is also shipped in zip format, which you can easilyextract with <i class="command">pkunzip</i> or<em class="emphasis">Winzip</em> (<a href="http://www.winzip.com">www.winzip.com</a>).</p><p>If you're building Perl under Unix, it is likelythat your architecture and development environment is supported by<em class="emphasis">Configure</em>. You shouldn't haveany problems with the build process or running the test suite. Onecommon problem is not making sure that Perl is linked against all thelibraries it needs to build correctly. Also, you should say"yes" when<em class="emphasis">Configure</em> asks if you want dynamic loading, ifyour system supports it. Otherwise, you won't beable to install modules that use XS, which provides an interfacebetween Perl and C.</p><p><a name="INDEX-52" />If you are running Linux, andyou've installed Perl from a tarball (or rpmpackage), you should make sure everything is there; one way to dothat is to check the<em class="emphasis">Config.pm</em><a name="INDEX-53" /> file. If MakeMaker is not correctlyinstalled, you might need to build Perl yourself.</p><p><a name="INDEX-54" />It's possibleyou'll get a compiled (<a name="INDEX-55" />binary) copy of Perl, rather thanthe source. In that case, make sure you get<em class="emphasis">suidperl</em>,<a href="#FOOTNOTE-2">[2]</a> <em class="emphasis">a2p</em>, <em class="emphasis">s2p</em>, andthe Perl library routines. Install these files in the directoriesthat your version was compiled for. Note that binary distributions ofPerl are made available because they're handy, notbecause you are restricted from getting the source and compiling ityourself. The people who give you the binary distribution ought toprovide you with some form of access to the source, if only a pointerto where <em class="emphasis">they</em> got the source. See the<em class="emphasis">Copying</em> file in the distribution for moreinformation.</p><blockquote class="footnote"> <a name="FOOTNOTE-2" /><p> [2]Be care ful with<em class="emphasis">suidperl</em>. Most people do not understand thecomplexities and pitfalls of <em class="emphasis">suidperl</em>. Also, itwill likely be deprecated after the Perl 5.8 release.</p></blockquote><a name="perlnut2-CHP-2-SECT-3.1.1" /><div class="sect3"><h3 class="sect3">2.3.1.1. Perl examples</h3><p><a name="INDEX-56" /><a name="INDEX-57" /><a name="INDEX-58" />The Perl source distribution comes withsome sample scripts in the <em class="emphasis">eg/</em> subdirectory.Feel free to browse among them and use them. They are not installedautomatically, however, so you need to copy them to the appropriatedirectory and possibly fix the <tt class="literal">#!</tt> line to point tothe right interpreter.</p><p>The files in the <em class="emphasis">t/</em> and<em class="emphasis">lib/</em> subdirectories, although arcane in spots,can also serve as examples.</p></div><a name="perlnut2-CHP-2-SECT-3.1.2" /><div class="sect3"><h3 class="sect3">2.3.1.2. Patches</h3><p><a name="INDEX-59" />Since Perl is constantly being honed andimproved, patches are sometimes made available through CPAN. Yourdistribution is likely to have had most of the patches appliedalready—run <tt class="literal">perl</tt> <tt class="literal">-v</tt> tocheck the patch level of your distribution. Patches are sent out withcomplete instructions on how to apply them using<em class="emphasis">patch</em>, which is available from the GNU project.</p></div></div><a name="perlnut2-CHP-2-SECT-3.2" /><div class="sect2"><h3 class="sect2">2.3.2. Installing on Win32</h3><p><a name="INDEX-60" />You need to obtain and install a copy ofPerl yourself, unless you have had the good fortune of having eithera system administrator install Perl on your system or access to a setof development tools to compile the Perl distribution.</p><p><a name="INDEX-61" />Theofficial precompiled Perl distribution for Win32 is<em class="emphasis">ActivePerl</em>, which is developed by ActiveStateTool Corporation (<a href="http://www.activestate.com">www.activestate.com</a>).You'll find that ActivePerl is quite complete, downto the availability of such modules as <em class="emphasis">Win32</em> and<em class="emphasis">mod_perl</em>.</p><p>When Perl 5.005 was released, Perl developers could build their own
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -