Scroll to navigation

PERLFAQ2(7) Perl Programmers Reference Guide PERLFAQ2(7)

NAME

perlfaq2 - 获取和学习 Perl (2003/10/16 04:57:38)

DESCRIPTION 描述

从哪里寻找 Perl 的源程序和文档,支持以及相关事项

哪些平台上有 Perl?要到哪里去找?

Perl的标准发行版(由 perl发展小组负责维护)仅以原始码形式发行。您可在 http://www.perl.com/CPAN/src/latest.tar.gz处取得。这个档案的格式是 POSIX tar档案柜,再以 gzip格式压缩。

Perl 可以在难以记数的平台上运行。几乎所有已知的 Unix 衍生版本都被支持 (Perl 的本地平台),还有其他操作系统平台,类似 VMS, DOS, OS/2, Windows, QNX, BeOS, OS X, MPE/iX 和 Amiga.

为专有平台准备的二进制发行版,包括 Apple,可以从 http://www.cpan.org/ports/ 找到。因为它们不是标准发行的一部分,它们可能(事实上的确)和基本的 Perl有多方面的不同。要确切知道到底哪些地方不同,您得自行查阅它们各自的发行说明。这些差异可能是正面的(譬如它们可能附有一些原始码发行的 perl所没有的延伸,提供专属某一平台的特殊功能),亦或负面的(例如它们可能是植基於比较老旧的 Perl原始码发行 版)。

要如何取得以二进制形式发行的 Perl?

不管为什麽您的作业系统业者没有将 C编译器附在所卖的作业系统中,最好的方法是到网路上去抓一份 gcc的执行档,然後用它来编译 perl 。 CPAN 上所放的 gcc执行档仅专门提供几个特别难拿到免费编译器的平台,而不是给任何 Unix系 统的。

一些 URLs 可能有用:

    http://www.cpan.org/ports/
    http://www.perl.com/pub/language/info/software.html

Someone looking for a Perl for Win16 might look to Laszlo Molnar's djgpp port in http://www.cpan.org/ports/#msdos , which comes with clear installation instructions. A simple installation guide for MS-DOS using Ilya Zakharevich's OS/2 port is available at http://www.cs.ruu.nl/%7Epiet/perl5dos.html and similarly for Windows 3.1 at http://www.cs.ruu.nl/%7Epiet/perlwin3.html .

我的系统里没有 C编译器。要如何编译 perl?

因为您没有 C 编译器,您是没指望了,而您的经销商则该拿去当作祭拜 Sun god 的供品。不过说这些风凉话无济於事。

您首先需要做的是替您的系统找一个 gcc的执行档。参阅和您的作业系统相关的 各 Usenet FAQs,看到哪里可以找到这种作业系统的 gcc执行档 。

我直接将 Perl的执行档从一台机器上复制到另一台机器上,但是程式跑不起来。

那大概是您忘了复制程式库,或者是程式库的路径不同的关系。您真的应该在那台要安装 perl的机器上将整套发行从头编译,然後打 make install来安装。其他的方法大多注定要失败。

有一个简单的方法可用来检查和确定东西有没有装对地方 --把编入 perl的 @INC阵列(perl用它来寻找程式库的路径)印出:

    % perl -le 'print for @INC'

如果这个指令列出了任何在您系统上不存在的路径,那麽您或许得将适当的程式库移到这些地方,或者制做适当的 symlinks、aliases 或捷径。@INC 也作为命令

    % perl -V

的输出。你也许会想看看 "How do I keep my own module/library directory?" in perlfaq8.

我抓回了原始码,试着编译 perl,但是 gdbm/dynamic loading/malloc/linking/...部分失败。要如何将它搞定?

细读 INSTALL这个档案,这是原始码发行版里面的一个档案。有时候自动设定程式 (Configure) 对某些较不寻常的系统、平台特质、或变异会不知所措。该档案对该如何处这类的问题,大都有详细的说明。

Perl有哪些模组和延伸? CPAN是什麽? CPAN/src/...又代表什麽?

CPAN代表的是「大 Perl档案库网络」(Comprehensive Perl Archive Network),一个在全世界近200台机器之间相互映射的巨大档案库。CPAN包含了原始码、对各非原生系统的移植、使用说明、程式,以及许多由第叁类团体所写的模组和延伸,从各商业品牌的资料库介面、到键盘/萤幕控制,乃至全球资讯网漫游及 CGI程式皆一应具全。CPAN的总主机是http://www.cpan.org/ ,但您也可以透过这个位址: http://www.cpan.org/CPAN.html 来自动连接一个在地理位置上最接近您的站。至於这个设计的运作原理,请看 http://www.perl.com/CPAN(最後头没有斜线)的说明。同时,http://mirror.cpan.org/ 也提供了 http://www.cpan.org/MIRRORED 的方便的界面

参见 CPAN FAQ 位于 http://www.cpan.org/misc/cpan-faq.html 来获得有关 CPAN 的 FAQ,包括如何成为一个镜像站

CPAN/path/... 是 CPAN站台上头的档案的命名规范。CPAN 代表一个 CPAN映射的基准目录,然後其馀的路径是由该目录到一个档案的路径。例如,如果您使用 ftp://ftp.funet.fi/pub/languages/perl/CPAN 来做您的 CPAN 站,那麽 CPAN/misc/japh这个档案便可以从 ftp://ftp.funet.fi/pub/languages/perl/CPAN/misc/japh 下载到

由於目前 CPAN档案库中已经有近两千个模组,因此几乎任何您所能想到的用途,大概都已经有现成的模组可以办到。目前在 CPAN/modules/by-category/ 底下的类 别包括了 perl核心模组、协助发展模组、作业系统介面、网路、周边设备、不同 processes间之沟通、资料型态工具、资料库介面、使用者介面、与其他语言介面、档名、档案系统、档案锁定、软体国际化及地方化、全球资讯网支援、伺服软体工具、档案库和档案压缩、图形变换处理、电子邮件及新闻讨论群、程式流程控制工具、filehandles和输入/输出、微软视窗模组,以及杂项模组 等。

参见 http://www.cpan.org/modules/00modlist.long.htmlhttp://search.cpan.org/ 来阅读分类的模块完整列表。

CPAN 不是 O'Reilly and Associates 的附属品.

是不是有一个经 ISO【国际标准局】或 ANSI【美国国家标准局】认可的 Perl版本?

当然没有。Larry认为他得先被认可後然後才会轮到 Perl 。

Perl的相关资料要上哪儿找?

perl的发行版中都附有完整的使用说明中。如果 perl已安装在您的机器上,那麽使用说明应该也已经装在上头了:如果您用的是一个像 Unix的系统,您可以打 man perl。这同时会带领您到其他重要的使用说明页。如果您用的不是 Unix 式的系统,那麽查阅使用说明的方法会有所不同;譬如说,使用说明可能会以HTML 格式来存放。不管怎麽样,只要 perl正确地安装,查阅使用说明应该不成问题。

如果您的系统没有 man这个指令,或者是该指令安装不当,那麽您可以试试 perldoc perl。如果还不成,您可以在 /usr/local/lib/perl5/pod这个目录 下找使用说明。

如果以上的方法全失败,那麽您可求助於 http://perldoc.cpan.org/http://www.perldoc.com/ 都提供了完整的 html 格式的帮助

面上有许多本和 Perl有关的好书,详情请见下面一节的介绍。

Tutorial documents are included in current or upcoming Perl releases include perltoot for objects or perlboot for a beginner's approach to objects, perlopentut for file opening semantics, perlreftut for managing references, perlretut for regular expressions, perlthrtut for threads, perldebtut for debugging, and perlxstut for linking C and Perl together. There may be more by the time you read this. The following URLs might also be of assistance:

    http://perldoc.cpan.org/
    http://www.perldoc.com/
    http://bookmarks.cpan.org/search.cgi?cat=Training%2FTutorials

USENET上有哪些专门讨论 Perl的新闻讨论群?问题该投到哪里?

Usenet 中有多个新闻组与 Perl 语言相关:

    comp.lang.perl.announce             Moderated announcement group
    comp.lang.perl.misc                 High traffic general Perl discussion
    comp.lang.perl.moderated        Moderated discussion group
    comp.lang.perl.modules              Use and development of Perl modules
    comp.lang.perl.tk                   Using Tk (and X) from Perl

    comp.infosystems.www.authoring.cgi  Writing CGI scripts for the Web.

Some years ago, comp.lang.perl was divided into those groups, and comp.lang.perl itself officially removed. While that group may still be found on some news servers, it is unwise to use it, because postings there will not appear on news servers which honour the official list of group names. Use comp.lang.perl.misc for topics which do not have a more-appropriate specific group.

There is also a Usenet gateway to Perl mailing lists sponsored by perl.org at nntp://nntp.perl.org , a web interface to the same lists at http://nntp.perl.org/group/ and these lists are also available under the "perl.*" hierarchy at http://groups.google.com . Other groups are listed at http://lists.perl.org/ ( also known as http://lists.cpan.org/ ).

A nice place to ask questions is the PerlMonks site, http://www.perlmonks.org/ , or the Perl Beginners mailing list http://lists.perl.org/showlist.cgi?name=beginners .

Note that none of the above are supposed to write your code for you: asking questions about particular problems or general advice is fine, but asking someone to write your code for free is not very cool.

如果我想投程式原始码,该投到哪个板子上?

您应看程式的性质来决定该丢到哪个板子上,但也欢迎您交叉投递一份到 comp.lang.perl.misc上头去。如果您打算交叉投递到 alt.sources 的话,请务必遵照该板所规定的标准,包括标头的 Followup-To 栏不可将 alt.sources 列入; 详见该板的 FAQ 。

If you're just looking for software, first use Google ( http://www.google.com ), Google's usenet search interface ( http://groups.google.com ), and CPAN Search ( http://search.cpan.org ). This is faster and more productive than just posting a request.

Perl 书籍

市面上有许多有关 Perl 和/或 CGI程式设计的书。其中有些很好,有些还过得去,但也有不少根本不值得买。大部分的 Perl书都列在 Tom Christiansen 所维护的列表中,其中一些有详细的评论,位于 http://www.perl.com/perl/critiques/index.html .

毫无争议地,最权威的 Perl参考书要数以下这本,由 Perl的创始者著作,现在是第三版 (July 2000):

    Programming Perl (the "Camel Book"):
        by Larry Wall, Tom Christiansen, and Jon Orwant
        0-596-00027-8  [3rd edition July 2000]
        http://www.oreilly.com/catalog/pperl3/
    (English, translations to several languages are also available)

The companion volume to the Camel containing thousands of real-world examples, mini-tutorials, and complete programs is:

    The Perl Cookbook (the "Ram Book"):
        by Tom Christiansen and Nathan Torkington,
            with Foreword by Larry Wall
        ISBN 1-56592-243-3 [1st Edition August 1998]
        http://perl.oreilly.com/catalog/cookbook/

If you're already a seasoned programmer, then the Camel Book might suffice for you to learn Perl from. If you're not, check out the Llama book:

    Learning Perl (the "Llama Book")
        by Randal L. Schwartz and Tom Phoenix
        ISBN 0-596-00132-0 [3rd edition July 2001]
        http://www.oreilly.com/catalog/lperl3/

And for more advanced information on writing larger programs, presented in the same style as the Llama book, continue your education with the Alpaca book:

    Learning Perl Objects, References, and Modules (the "Alpaca Book")
       by Randal L. Schwartz, with Tom Phoenix (foreword by Damian Conway)
       ISBN 0-596-00478-8 [1st edition June 2003]
       http://www.oreilly.com/catalog/lrnperlorm/

If you're not an accidental programmer, but a more serious and possibly even degreed computer scientist who doesn't need as much hand-holding as we try to provide in the Llama, please check out the delightful book

    Perl: The Programmer's Companion
        by Nigel Chapman
        ISBN 0-471-97563-X [1997, 3rd printing Spring 1998]
        http://www.wiley.com/compbooks/catalog/97563-X.htm
        http://www.wiley.com/compbooks/chapman/perl/perltpc.html (errata etc)

If you are more at home in Windows the following is available (though unfortunately rather dated).

    Learning Perl on Win32 Systems (the "Gecko Book")
        by Randal L. Schwartz, Erik Olson, and Tom Christiansen,
            with foreword by Larry Wall
        ISBN 1-56592-324-3 [1st edition August 1997]
        http://www.oreilly.com/catalog/lperlwin/

Addison-Wesley ( http://www.awlonline.com/ ) and Manning ( http://www.manning.com/ ) are also publishers of some fine Perl books such as Object Oriented Programming with Perl by Damian Conway and Network Programming with Perl by Lincoln Stein.

An excellent technical book discounter is Bookpool at http://www.bookpool.com/ where a 30% discount or more is not unusual.

What follows is a list of the books that the FAQ authors found personally useful. Your mileage may (but, we hope, probably won't) vary.

Recommended books on (or mostly on) Perl follow.

    Programming Perl
        by Larry Wall, Tom Christiansen, and Jon Orwant
        ISBN 0-596-00027-8 [3rd edition July 2000]
        http://www.oreilly.com/catalog/pperl3/
    

    Perl 5 Pocket Reference
    by Johan Vromans
        ISBN 0-596-00032-4 [3rd edition May 2000]
        http://www.oreilly.com/catalog/perlpr3/
    

    Perl in a Nutshell
    by Ellen Siever, Stephan Spainhour, and Nathan Patwardhan
        ISBN 1-56592-286-7 [1st edition December 1998]
        http://www.oreilly.com/catalog/perlnut/
    
    Elements of Programming with Perl
        by Andrew L. Johnson
        ISBN 1-884777-80-5 [1st edition October 1999]
        http://www.manning.com/Johnson/
    

    Learning Perl
        by Randal L. Schwartz and Tom Phoenix
        ISBN 0-596-00132-0 [3rd edition July 2001]
        http://www.oreilly.com/catalog/lperl3/
    

    Learning Perl Objects, References, and Modules
       by Randal L. Schwartz, with Tom Phoenix (foreword by Damian Conway)
       ISBN 0-596-00478-8 [1st edition June 2003]
       http://www.oreilly.com/catalog/lrnperlorm/
    

    Learning Perl on Win32 Systems
        by Randal L. Schwartz, Erik Olson, and Tom Christiansen,
            with foreword by Larry Wall
        ISBN 1-56592-324-3 [1st edition August 1997]
        http://www.oreilly.com/catalog/lperlwin/
    

    Perl: The Programmer's Companion
        by Nigel Chapman
        ISBN 0-471-97563-X [1997, 3rd printing Spring 1998]
    http://www.wiley.com/compbooks/catalog/97563-X.htm
    http://www.wiley.com/compbooks/chapman/perl/perltpc.html (errata etc)
    

    Cross-Platform Perl
        by Eric Foster-Johnson
        ISBN 1-55851-483-X [2nd edition September 2000]
        http://www.pconline.com/~erc/perlbook.htm
    

    MacPerl: Power and Ease
        by Vicki Brown and Chris Nandor,
            with foreword by Matthias Neeracher
        ISBN 1-881957-32-2 [1st edition May 1998]
        http://www.macperl.com/ptf_book/
    
    The Perl Cookbook
        by Tom Christiansen and Nathan Torkington
            with foreword by Larry Wall
        ISBN 1-56592-243-3 [1st edition August 1998]
        http://www.oreilly.com/catalog/cookbook/
    

    Effective Perl Programming
        by Joseph Hall
        ISBN 0-201-41975-0 [1st edition 1998]
        http://www.awl.com/
    
    Mastering Regular Expressions
        by Jeffrey E. F. Friedl
        ISBN 0-596-00289-0 [2nd edition July 2002]
        http://www.oreilly.com/catalog/regex2/
    

    Network Programming with Perl
        by Lincoln Stein
        ISBN 0-201-61571-1 [1st edition 2001]
        http://www.awlonline.com/
    

    Object Oriented Perl
        Damian Conway
            with foreword by Randal L. Schwartz
        ISBN 1-884777-79-1 [1st edition August 1999]
        http://www.manning.com/Conway/
    

    Data Munging with Perl
        Dave Cross
        ISBN 1-930110-00-6 [1st edition 2001]
        http://www.manning.com/cross
    

    Mastering Perl/Tk
        by Steve Lidie and Nancy Walsh
        ISBN 1-56592-716-8 [1st edition January 2002]
        http://www.oreilly.com/catalog/mastperltk/
    

    Extending and Embedding Perl
       by Tim Jenness and Simon Cozens
       ISBN 1-930110-82-0 [1st edition August 2002]
       http://www.manning.com/jenness
    

和 Perl 有关的杂志

The first (and for a long time, only) periodical devoted to All Things Perl, The Perl Journal contains tutorials, demonstrations, case studies, announcements, contests, and much more. TPJ has columns on web development, databases, Win32 Perl, graphical programming, regular expressions, and networking, and sponsors the Obfuscated Perl Contest and the Perl Poetry Contests. Beginning in November 2002, TPJ moved to a reader-supported monthly e-zine format in which subscribers can download issues as PDF documents. For more details on TPJ, see http://www.tpj.com/

Beyond this, magazines that frequently carry quality articles on Perl are The Perl Review ( http://www.theperlreview.com ), Unix Review ( http://www.unixreview.com/ ), Linux Magazine ( http://www.linuxmagazine.com/ ), and Usenix's newsletter/magazine to its members, login: ( http://www.usenix.org/ )

The Perl columns of Randal L. Schwartz are available on the web at http://www.stonehenge.com/merlyn/WebTechniques/ , http://www.stonehenge.com/merlyn/UnixReview/ , and http://www.stonehenge.com/merlyn/LinuxMag/ .

网路上的 Perl:接触 FTP 和 WWW

如果您想达到最好(还有最省钱)的传输效果,那麽从 http://www.cpan.org/SITES.html 所列的站台中任选其一,从上头把完整的映射站名单抓下来。然後您可以从中挑选一个对您来说传输最快的站台。.PP 也可以使用 xx.cpan.org ,其中 "xx" 是双字符的国家代码,例如澳大利亚可以使用 au.cpan.org. [注意:这只对至少包含了一个主机镜像的国家有效。]

有哪些讨论 Perl 的邮件列表?

大部分的重要模组(如 Tk、CGI 和 libwww-perl)有专属各自的 mailing lists。有关资料请参考这些模组的使用说明。

完整的与 Perl 有关的邮件列表可以从这里找到:

        http://lists.perl.org/

comp.lang.perl.misc 的档案库

The Google search engine now carries archived and searchable newsgroup content.

http://groups.google.com/groups?group=comp.lang.perl.misc

If you have a question, you can be sure someone has already asked the same question at some point on c.l.p.m. It requires some time and patience to sift through all the content but often you will find the answer you seek.

如何购买商业版本的 Perl?

在某种程度上来说,Perl 已经算是商业软体了:您可以把 Perl的发行约定拿来细读给您的经理听。各发行版都附有这份条例清楚、明确的公约。Perl有广大的使用者及广泛的文献。comp.lang.perl.*等新闻讨论群组和各电子邮递论坛更是对各种疑难杂症提供迅速的解答。Perl 传统上一直是由 Larry、许多软体设计工程师,以及成千上万的程式写作者提供支援,大伙协力让人人过更美好的日子。

尽管如此,有些主管坚持只向附售後保证的公司下订单,这样子出了问题才可以告他们,故以上的回答可能无法令这类的经理满意。或许是这类的主管觉得亦步亦趋的扶持支援及很强的合约义务有其必要。市面上有卖用玻璃纸密封包装的 Perl 光碟,您可以试试看,或许对您的经理有效。

Alternatively, you can purchase commercial incidence based support through the Perl Clinic. The following is a commercial from them:

"The Perl Clinic is a commercial Perl support service operated by ActiveState Tool Corp. and The Ingram Group. The operators have many years of in-depth experience with Perl applications and Perl internals on a wide range of platforms.

"Through our group of highly experienced and well-trained support engineers, we will put our best effort into understanding your problem, providing an explanation of the situation, and a recommendation on how to proceed."

Contact The Perl Clinic at

    www.PerlClinic.com

    North America Pacific Standard Time (GMT-8)
    Tel:    1 604 606-4611 hours 8am-6pm
    Fax:    1 604 606-4640

    Europe (GMT)
    Tel:    00 44 1483 862814
    Fax:    00 44 1483 862801

See also www.perl.com for updates on tutorials, training, and support.

如果发现 bugs要向何处报告?

如果您发现 perl解译器或标准发行中的模组有 bugs ,想报知 perl 发布小组的 话,请使用 perl发行中所附的 perlbug 程式,或将您的报告 email 到 perlbug@perl.org .

如果您想报告的 bug是有关某个非标准发行的 perl(详见「哪些平台上有 Perl ?」一题的答案)、某可执行档形式的发行,或是某非标准的模组(譬如 Tk、CGI 等),那麽请参考它所附的使用说明,以确定最合适报告 bugs的地方。

详情请见 perlbug(1) 手册页 (perl5.004 或更新版本)。

什麽是 perl.com? Perl Mongers? pm.org? perl.org? cpan.org?

The Perl Home Page at http://www.perl.com/ is currently hosted by The O'Reilly Network, a subsidiary of O'Reilly and Associates.

Perl Mongers is an advocacy organization for the Perl language which maintains the web site http://www.perl.org/ as a general advocacy site for the Perl language.

Perl Mongers uses the pm.org domain for services related to Perl user groups, including the hosting of mailing lists and web sites. See the Perl user group web site at http://www.pm.org/ for more information about joining, starting, or requesting services for a Perl user group.

Perl Mongers also maintain the perl.org domain to provide general support services to the Perl community, including the hosting of mailing lists, web sites, and other services. The web site http://www.perl.org/ is a general advocacy site for the Perl language, and there are many other sub-domains for special topics, such as

    http://bugs.perl.org/
    http://history.perl.org/
    http://lists.perl.org/
    http://use.perl.org/

http://www.cpan.org/ is the Comprehensive Perl Archive Network, a replicated worlwide repository of Perl software, see the What is CPAN? question earlier in this document.

AUTHOR AND COPYRIGHT

Copyright (c) 1997-2001 Tom Christiansen and Nathan Torkington. All rights reserved.

This documentation is free; you can redistribute it and/or modify it under the same terms as Perl itself.

Irrespective of its distribution, all code examples here are in the public domain. You are permitted and encouraged to use this code and any derivatives thereof in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit to the FAQ would be courteous but is not required.

译者

萧百龄,两只老虎工作室

2003-11-25 perl v5.8.3