Imported upstream version 1.5
[manpages-zh.git] / src / man1 / perlfaq3.1
blobf2a4508e0c959e40a980406c226909725aa05b11
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  | will give a
29 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used to
30 .\" do unbreakable dashes and therefore won't be available.  \*(C` and \*(C'
31 .\" expand to `' in nroff, nothing in troff, for use with C<>.
32 .tr \(*W-|\(bv\*(Tr
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
131 .IX Title "PERLFAQ3 1"
132 .TH PERLFAQ3 1 "2003-11-25" "perl v5.8.3" "Perl Programmers Reference Guide"
133 .SH "NAME"
134 perlfaq3 \- 编程工具 (2003/11/24 19:55:50)
135 .SH "DESCRIPTION 描述"
136 .IX Header "DESCRIPTION"
137 编程工具和编程支持
138 .Sh "我如何作 (任何事)?"
139 .IX Subsection "How do I do (anything)?"
140 你到 CPAN(见 perlfaq2)找过了吗?也许别人已经写了某个模组可以解决你的问题。你查过相关的说明文件了吗 (man pages)?以下是一份概要的索引:
142 .Vb 12
143 \&        基础Basics          perldata, perlvar, perlsyn, perlop, perlsub
144 \&        执行Execution       perlrun, perldebug
145 \&        函数Functions       perlfunc
146 \&        对象Objects         perlref, perlmod, perlobj, perltie
147 \&        数据结构Data Structures perlref, perllol, perldsc
148 \&        模块Modules         perlmod, perlmodlib, perlsub
149 \&        正则表达式Regexes         perlre, perlfunc, perlop, perllocale
150 \&        移植Moving to perl5 perltrap, perl
151 \&        连接Linking w/C     perlxstut, perlxs, perlcall, perlguts, perlembed
152 \&        其他Various         http://www.cpan.org/misc/olddoc/FMTEYEWTK.tgz
153 \&                        (这不是一个手册页,但是仍然很有用
154 \&                         是有关 Perl 技术的大量技巧)
157 perltoc里有一份粗略的 perl 说明文件组的目录
158 .Sh "如何以交互的方式使用 Perl?"
159 .IX Subsection "How can I use Perl interactively?"
160 典型的作法是使用 perldebug(1)说明文件里提到的 Perl 除虫器,在一个「空的」(译者:即不存在的)程式上执行,像这样:
162 .Vb 1
163 \&    perl -de 42
166 接下来所打入的任意合法 Perl程式码皆会立刻被计算。同时,你可以检查符号表 (symbol table)、取得堆叠的记录 (stack backtraces)、检视变数值、设定阻断点 (set breakpoints) 以及其他符号式除虫器 (symbolic debuggers) 所能作的动作。
167 .Sh "有 Perl shell吗?"
168 .IX Subsection "Is there a Perl shell?"
169 The psh (Perl sh) is currently at version 1.8. The Perl Shell is a
170 shell that combines the interactive nature of a Unix shell with the
171 power of Perl. The goal is a full featured shell that behaves as
172 expected for normal shell activity and uses Perl syntax and
173 functionality for control-flow statements and other things.
174 You can get psh at http://www.focusresearch.com/gregor/psh/ .
176 Zoidberg is a similar project and provides a shell written in perl,
177 configured in perl and operated in perl. It is intended as a login shell
178 and development environment. It can be found at http://zoidberg.sf.net/
179 or your local \s-1CPAN\s0 mirror.
181 The Shell.pm module (distributed with Perl) makes Perl try commands
182 which aren't part of the Perl language as shell commands.  perlsh
183 from the source distribution is simplistic and uninteresting, but
184 may still be what you want.
185 .Sh "怎样查找我的系统中安装了哪些模块?"
186 .IX Subsection "How do I find which modules are installed on my system?"
187 You can use the ExtUtils::Installed module to show all
188 installed distributions, although it can take awhile to do
189 its magic.  The standard library which comes with Perl just
190 shows up as \*(L"Perl\*(R" (although you can get those with
191 Module::CoreList).
193 .Vb 1
194 \&        use ExtUtils::Installed;
197 .Vb 2
198 \&        my $inst    = ExtUtils::Installed->new();
199 \&        my @modules = $inst->modules();
202 If you want a list of all of the Perl module filenames, you
203 can use File::Find::Rule.
205 .Vb 1
206 \&        use File::Find::Rule;
209 .Vb 1
210 \&        my @files = File::Find::Rule->file()->name( '*.pm' )->in( @INC );
213 If you do not have that module, you can do the same thing
214 with File::Find which is part of the standard library.
216 .Vb 2
217 \&    use File::Find;
218 \&    my @files;
221 .Vb 2
222 \&    find sub { push @files, $File::Find::name if -f _ && /\e.pm$/ },
223 \&         @INC;
226 .Vb 1
227 \&        print join "\en", @files;
230 If you simply need to quickly check to see if a module is
231 available, you can check for its documentation.  If you can
232 read the documentation the module is most likely installed.
233 If you cannot read the documentation, the module might not
234 have any (in rare cases).
236 .Vb 1
237 \&        prompt% perldoc Module::Name
240 You can also try to include the module in a one-liner to see if
241 perl finds it.
243 .Vb 1
244 \&        perl -MModule::Name -e1
246 .Sh "如何替我的 Perl 程式除虫?"
247 .IX Subsection "How do I debug my Perl programs?"
248 你用过 \f(CW\*(C`use warnings\*(C'\fR 或 \f(CW\*(C`\-w\*(C'\fR 吗?它们启用警告模式,来检测不确定的代码。
250 你用过 \f(CW\*(C`use strict\*(C'\fR 吗?It prevents you from using symbolic
251 references, makes you predeclare any subroutines that you call as bare
252 words, and (probably most importantly) forces you to predeclare your
253 variables with \f(CW\*(C`my\*(C'\fR, \f(CW\*(C`our\*(C'\fR, or \f(CW\*(C`use vars\*(C'\fR.
255 Did you check the return values of each and every system call?  The operating
256 system (and thus Perl) tells you whether they worked, and if not
257 why.
259 .Vb 2
260 \&  open(FH, "> /etc/cantwrite")
261 \&    or die "Couldn't write to /etc/cantwrite: $!\en";
264 Did you read perltrap?  It's full of gotchas for old and new Perl
265 programmers and even has sections for those of you who are upgrading
266 from languages like \fIawk\fR and \fIC\fR.
268 Have you tried the Perl debugger, described in perldebug?  You can
269 step through your program and see what it's doing and thus work out
270 why what it's doing isn't what it should be doing.
271 .Sh "如何检测 (profile) 我的 perl 程式?"
272 .IX Subsection "How do I profile my Perl programs?"
273 你该自 CPAN抓取 Devel::DProf 模组,并且使用 perl 标准套件所附的 Benchmark.pm。 Benchmark.pm让你测量程式码的某部份在执行上所花的时间,而 Devel::DProf则详细地替你分析哪一部份的程式用掉多少时间。
275 Here's a sample use of Benchmark:
277 .Vb 1
278 \&  use Benchmark;
281 .Vb 2
282 \&  @junk = `cat /etc/motd`;
283 \&  $count = 10_000;
286 .Vb 8
287 \&  timethese($count, {
288 \&            'map' => sub { my @a = @junk;
289 \&                           map { s/a/b/ } @a;
290 \&                           return @a },
291 \&            'for' => sub { my @a = @junk;
292 \&                           for (@a) { s/a/b/ };
293 \&                           return @a },
294 \&           });
297 This is what it prints (on one machine\*(--your results will be dependent
298 on your hardware, operating system, and the load on your machine):
300 .Vb 3
301 \&  Benchmark: timing 10000 iterations of for, map...
302 \&         for:  4 secs ( 3.97 usr  0.01 sys =  3.98 cpu)
303 \&         map:  6 secs ( 4.97 usr  0.00 sys =  4.97 cpu)
306 Be aware that a good benchmark is very hard to write.  It only tests the
307 data you give it and proves little about the differing complexities
308 of contrasting algorithms.
309 .Sh "如何替我的 Perl程式作交叉参考?"
310 .IX Subsection "How do I cross-reference my Perl programs?"
311 B::Xref模组可 以替你的 Perl程式制作 cross-reference报告。用法是:
313 .Vb 1
314 \&    perl -MO=Xref[,OPTIONS] scriptname.plx
316 .Sh "有 Perl专用的美化列印程式吗?"
317 .IX Subsection "Is there a pretty-printer (formatter) for Perl?"
318 Perltidy is a Perl script which indents and reformats Perl scripts
319 to make them easier to read by trying to follow the rules of the
320 perlstyle. If you write Perl scripts, or spend much time reading
321 them, you will probably find it useful.  It is available at
322 http://perltidy.sourceforge.net
324 Of course, if you simply follow the guidelines in perlstyle,
325 you shouldn't need to reformat.  The habit of formatting your code
326 as you write it will help prevent bugs.  Your editor can and should
327 help you with this.  The perl-mode or newer cperl-mode for emacs
328 can provide remarkable amounts of help with most (but not all)
329 code, and even less programmable editors can provide significant
330 assistance.  Tom Christiansen and many other \s-1VI\s0 users  swear by
331 the following settings in vi and its clones:
333 .Vb 2
334 \&    set ai sw=4
335 \&    map! ^O {^M}^[O^T
338 Put that in your \fI.exrc\fR file (replacing the caret characters
339 with control characters) and away you go.  In insert mode, ^T is
340 for indenting, ^D is for undenting, and ^O is for blockdenting\*(--
341 as it were.  A more complete example, with comments, can be found at
342 http://www.cpan.org/authors/id/TOMC/scripts/toms.exrc.gz
344 The a2ps http://www\-inf.enst.fr/%7Edemaille/a2ps/black+white.ps.gz does
345 lots of things related to generating nicely printed output of
346 documents, as does enscript at http://people.ssh.fi/mtr/genscript/ .
347 .Sh "有 Perl的 ctags 吗?"
348 .IX Subsection "Is there a ctags for Perl?"
349 Recent versions of ctags do much more than older versions did.
350 \&\s-1EXUBERANT\s0 \s-1CTAGS\s0 is available from http://ctags.sourceforge.net/
351 and does a good job of making tags files for perl code.
353 There is also a simple one at
354 http://www.cpan.org/authors/id/TOMC/scripts/ptags.gz which may do
355 the trick.  It can be easy to hack this into what you want.
356 .Sh "Is there an \s-1IDE\s0 or Windows Perl Editor?"
357 .IX Subsection "Is there an IDE or Windows Perl Editor?"
358 Perl programs are just plain text, so any editor will do.
360 If you're on Unix, you already have an IDE\*(--Unix itself.  The \s-1UNIX\s0
361 philosophy is the philosophy of several small tools that each do one
362 thing and do it well.  It's like a carpenter's toolbox.
364 If you want an \s-1IDE\s0, check the following:
365 .IP "Komodo" 4
366 .IX Item "Komodo"
367 ActiveState's cross-platform (as of April 2001 Windows and Linux),
368 multi-language \s-1IDE\s0 has Perl support, including a regular expression
369 debugger and remote debugging
370 ( http://www.ActiveState.com/Products/Komodo/index.html ).  (Visual
371 Perl, a Visual Studio.NET plug-in is currently (early 2001) in beta
372 ( http://www.ActiveState.com/Products/VisualPerl/index.html )).
373 .IP "The Object System" 4
374 .IX Item "The Object System"
375 ( http://www.castlelink.co.uk/object_system/ ) is a Perl web
376 applications development \s-1IDE\s0, apparently for any platform
377 that runs Perl.
378 .IP "Open Perl \s-1IDE\s0" 4
379 .IX Item "Open Perl IDE"
380 ( http://open\-perl\-ide.sourceforge.net/ )
381 Open Perl \s-1IDE\s0 is an integrated development environment for writing
382 and debugging Perl scripts with ActiveState's ActivePerl distribution
383 under Windows 95/98/NT/2000.
384 .IP "PerlBuilder" 4
385 .IX Item "PerlBuilder"
386 ( http://www.solutionsoft.com/perl.htm ) is an integrated development
387 environment for Windows that supports Perl development.
388 .IP "visiPerl+" 4
389 .IX Item "visiPerl+"
390 ( http://helpconsulting.net/visiperl/ )
391 From Help Consulting, for Windows.
392 .IP "OptiPerl" 4
393 .IX Item "OptiPerl"
394 ( http://www.optiperl.com/ ) is a Windows \s-1IDE\s0 with simulated \s-1CGI\s0
395 environment, including debugger and syntax highlighting editor.
397 For editors: if you're on Unix you probably have vi or a vi clone already,
398 and possibly an emacs too, so you may not need to download anything.
399 In any emacs the cperl-mode (M\-x cperl\-mode) gives you perhaps the
400 best available Perl editing mode in any editor.
402 If you are using Windows, you can use any editor that lets
403 you work with plain text, such as NotePad or WordPad.  Word
404 processors, such as Microsoft Word or WordPerfect, typically
405 do not work since they insert all sorts of behind-the-scenes
406 information, although some allow you to save files as \*(L"Text
407 Only\*(R". You can also download text editors designed
408 specifically for programming, such as Textpad
409 ( http://www.textpad.com/ ) and UltraEdit
410 ( http://www.ultraedit.com/ ), among others.
412 If you are using MacOS, the same concerns apply.  MacPerl
413 (for Classic environments) comes with a simple editor.
414 Popular external editors are BBEdit ( http://www.bbedit.com/ )
415 or Alpha ( http://www.kelehers.org/alpha/ ). MacOS X users can
416 use Unix editors as well.
417 .IP "\s-1GNU\s0 Emacs" 4
418 .IX Item "GNU Emacs"
419 http://www.gnu.org/software/emacs/windows/ntemacs.html
420 .IP "MicroEMACS" 4
421 .IX Item "MicroEMACS"
422 http://www.microemacs.de/
423 .IP "XEmacs" 4
424 .IX Item "XEmacs"
425 http://www.xemacs.org/Download/index.html
426 .IP "Jed" 4
427 .IX Item "Jed"
428 http://space.mit.edu/~davis/jed/
430 or a vi clone such as
431 .IP "Elvis" 4
432 .IX Item "Elvis"
433 ftp://ftp.cs.pdx.edu/pub/elvis/ http://www.fh\-wedel.de/elvis/
434 .IP "Vile" 4
435 .IX Item "Vile"
436 http://dickey.his.com/vile/vile.html
437 .IP "Vim" 4
438 .IX Item "Vim"
439 http://www.vim.org/
441 For vi lovers in general, Windows or elsewhere:
443 .Vb 1
444 \&        http://www.thomer.com/thomer/vi/vi.html
447 nvi ( http://www.bostic.com/vi/ , available from \s-1CPAN\s0 in src/misc/) is
448 yet another vi clone, unfortunately not available for Windows, but in
449 \&\s-1UNIX\s0 platforms you might be interested in trying it out, firstly because
450 strictly speaking it is not a vi clone, it is the real vi, or the new
451 incarnation of it, and secondly because you can embed Perl inside it
452 to use Perl as the scripting language.  nvi is not alone in this,
453 though: at least also vim and vile offer an embedded Perl.
455 The following are Win32 multilanguage editor/IDESs that support Perl:
456 .IP "Codewright" 4
457 .IX Item "Codewright"
458 http://www.starbase.com/
459 .IP "MultiEdit" 4
460 .IX Item "MultiEdit"
461 http://www.MultiEdit.com/
462 .IP "SlickEdit" 4
463 .IX Item "SlickEdit"
464 http://www.slickedit.com/
466 There is also a toyedit Text widget based editor written in Perl
467 that is distributed with the Tk module on \s-1CPAN\s0.  The ptkdb
468 ( http://world.std.com/~aep/ptkdb/ ) is a Perl/tk based debugger that
469 acts as a development environment of sorts.  Perl Composer
470 ( http://perlcomposer.sourceforge.net/ ) is an \s-1IDE\s0 for Perl/Tk
471 \&\s-1GUI\s0 creation.
473 In addition to an editor/IDE you might be interested in a more
474 powerful shell environment for Win32.  Your options include
475 .IP "Bash" 4
476 .IX Item "Bash"
477 from the Cygwin package ( http://sources.redhat.com/cygwin/ )
478 .IP "Ksh" 4
479 .IX Item "Ksh"
480 from the \s-1MKS\s0 Toolkit ( http://www.mks.com/ ), or the Bourne shell of
481 the U/WIN environment ( http://www.research.att.com/sw/tools/uwin/ )
482 .IP "Tcsh" 4
483 .IX Item "Tcsh"
484 ftp://ftp.astron.com/pub/tcsh/ , see also
485 http://www.primate.wisc.edu/software/csh\-tcsh\-book/
486 .IP "Zsh" 4
487 .IX Item "Zsh"
488 ftp://ftp.blarg.net/users/amol/zsh/ , see also http://www.zsh.org/
490 \&\s-1MKS\s0 and U/WIN are commercial (U/WIN is free for educational and
491 research purposes), Cygwin is covered by the \s-1GNU\s0 Public License (but
492 that shouldn't matter for Perl use).  The Cygwin, \s-1MKS\s0, and U/WIN all
493 contain (in addition to the shells) a comprehensive set of standard
494 \&\s-1UNIX\s0 toolkit utilities.
496 If you're transferring text files between Unix and Windows using \s-1FTP\s0
497 be sure to transfer them in \s-1ASCII\s0 mode so the ends of lines are
498 appropriately converted.
500 On Mac \s-1OS\s0 the MacPerl Application comes with a simple 32k text editor
501 that behaves like a rudimentary \s-1IDE\s0.  In contrast to the MacPerl Application
502 the \s-1MPW\s0 Perl tool can make use of the \s-1MPW\s0 Shell itself as an editor (with
503 no 32k limit).
504 .IP "BBEdit and BBEdit Lite" 4
505 .IX Item "BBEdit and BBEdit Lite"
506 are text editors for Mac \s-1OS\s0 that have a Perl sensitivity mode
507 ( http://web.barebones.com/ ).
508 .IP "Alpha" 4
509 .IX Item "Alpha"
510 is an editor, written and extensible in Tcl, that nonetheless has
511 built in support for several popular markup and programming languages
512 including Perl and \s-1HTML\s0 ( http://alpha.olm.net/ ).
514 Pepper and Pe are programming language sensitive text editors for Mac
515 \&\s-1OS\s0 X and BeOS respectively ( http://www.hekkelman.com/ ).
516 .Sh "哪儿有 vi 用的 Perl 宏?"
517 .IX Subsection "Where can I get Perl macros for vi?"
518 For a complete version of Tom Christiansen's vi configuration file,
519 see http://www.cpan.org/authors/Tom_Christiansen/scripts/toms.exrc.gz ,
520 the standard benchmark file for vi emulators.  The file runs best with nvi,
521 the current version of vi out of Berkeley, which incidentally can be built
522 with an embedded Perl interpreter\*(--see http://www.cpan.org/src/misc/ .
523 .Sh "给 emacs用的 perl模式又要去哪抓呢?"
524 .IX Subsection "Where can I get perl-mode for emacs?"
525 从大约 Emacs 19.22版 (version 19 patchlevel 22)起,已内含了 perl-mode.el及 perl 除虫器的支援。它们应该会和标准的 Emacs 19版一起出货。
527 在 perl原始码的目录下,你会找到一个叫作 ``emacs'' 的目录,里面包括一个 cperl-mode 可以把程式中的关键字上色、提供内文相关的协助以及其它方便的功能。
529 注意:``main'foo''(其中的单引号)会让 emacs的 perl-mode 出问题,并且会弄乱内 缩 (indentation) 与高亮 (hilighting)。不过你本来就该用 ``main::foo''的 (译者按: main'foo 是表示模组或 package的旧式写法;新式的 [perl5的]写法是 main::foo)。
530 .Sh "如何在 Perl里使用 curses?"
531 .IX Subsection "How can I use curses with Perl?"
532 The Curses module from \s-1CPAN\s0 provides a dynamically loadable object
533 module interface to a curses library.  A small demo can be found at the
534 directory http://www.cpan.org/authors/Tom_Christiansen/scripts/rep.gz ;
535 this program repeats a command and updates the screen as needed, rendering
536 \&\fBrep ps axu\fR similar to \fBtop\fR.
537 .Sh "X或 Tk如何与 Perl配合呢?"
538 .IX Subsection "How can I use X or Tk with Perl?"
539 Tk 模块是一个完全以 Perl 为基础,面向对象的接口,让你不用学 Tcl也可以使用 Tk工具组。Sx则是 Athena Widget set专用的介面。两者都可在 CPAN取得。参见分类 http://www.cpan.org/modules/by\-category/08_User_Interfaces/
541 Invaluable for Perl/Tk programming are the Perl/Tk \s-1FAQ\s0 at
542 http://w4.lns.cornell.edu/%7Epvhp/ptk/ptkTOC.html , the Perl/Tk Reference
543 Guide available at
544 http://www.cpan.org/authors/Stephen_O_Lidie/ , and the
545 online manpages at
546 http://www\-users.cs.umn.edu/%7Eamundson/perl/perltk/toc.html .
547 .Sh "如何不靠 CGI或 Tk 帮助作出简单的目录(选单)?"
548 .IX Subsection "How can I generate simple menus without using CGI or Tk?"
549 http://www.cpan.org/authors/id/SKUNZ/perlmenu.v4.0.tar.gz
550 是个以 curses为基础的模组,可以达成你的要求。
551 .Sh "如何让我的 Perl程式跑得更快些?"
552 .IX Subsection "How can I make my Perl program run faster?"
553 最好是能设计一个较好的演算法 (algorithm),这通常会让程式有大不相同的表现。Jon Bentley's book \fIProgramming Pearls\fR (没有拼写错误!) 中有些你或许想知道的增进效率小技巧。
554 Advice on benchmarking boils down to: benchmark
555 and profile to make sure you're optimizing the right part, look for
556 better algorithms instead of microtuning your code, and when all else
557 fails consider just buying faster hardware.  You will probably want to
558 read the answer to the earlier question ``How do I profile my Perl
559 programs?'' if you haven't done so already.
561 其它方法包括自动载入较少使用的 Perl 程式码。请参看标准 perl 套件中的 AutoSplit及 AutoLoader模组的用法。或当你能断定程式执行效率的瓶颈在何处时,用 C来写那个部份,就像用组合语言来撰写 C程式的瓶颈部份一样。与此法相近的是使用以 C撰写瓶 颈部份的模组 (例如 CPAN中的 PDL 模组)。
563 如果你目前是将你的 perl直译器动态连结到 libc.so的话,重新作一份静态连结到 libc.a的 perl直译器可以提高 10-25%的执行效能。虽然这会使你的 perl直译器变得更胖,但你的 Perl程式 (及程式设计者) 或许会因此而感谢你。详情请参考 perl标准套件原始码版本中的 INSTALL 档案。
565 使用 undump程式把编译後的档案格式存到硬碟里以加快执行的速度已经是老掉牙的手法了。它已不再是个可行的方法,因为这方法只有几种平台能用,况且它终究不是个治本之 道。
566 .Sh "如何让我的 Perl 程序少用一些内存?"
567 .IX Subsection "How can I make my Perl program take less memory?"
568 当问题变成时间与空间的交易时, Perl 几乎总是用记忆体来帮忙解决问题。 Perl中的纯量 (Scalar) 耗掉的记忆体比 C中的字串形态还多,阵列又更多, 更别谈杂凑阵列了 (Hashes)。关於这一点,我们当然还有很多工作得作,近来发布的版本,已开始针对这些问题做改进了。例如, 5.004 版中, 重复的散列键 (duplicate hash keys) 由使用它的杂凑阵列共用,这样就不用再重新定份位置给它了。
570 在某些情况下,使用 substr()或 vec()来模拟数组有很大的好处。例如,一个有上千 个布林代数值的阵列将占用至少 20,000位元组的空间,但是它可以被转变为一个 125位元组的位元向量 (bit vector)以节省相当可观的记忆体。标准套件中的 Tie::SubstrHash模组也能够帮助特定形态的资料结构节省些记忆体。若你正在和一些特殊的资料结构奋战 (例如,矩阵),用 C写的模组所耗掉的记忆体可能低於同功能并用 Perl写的模组。
572 另一件值得一试的是,查一下你的 Perl是以系统内的 malloc 还是 Perl内含的 malloc 编译起来的。不论是哪个,试着换成另一个,再看看这是否造成任何差别。关於 malloc的资讯可在 perl标准套件原始码版中的 INSTALL 档案找到。键入 \f(CW\*(C`perl \-V:usemymalloc\*(C'\fR. 就可以知道你是否在使用 perl的 malloc。
574 Of course, the best way to save memory is to not do anything to waste
575 it in the first place. Good programming practices can go a long way
576 toward this:
577 .IP "* Don't slurp!" 4
578 .IX Item "Don't slurp!"
579 Don't read an entire file into memory if you can process it line
580 by line. Or more concretely, use a loop like this:
582 .Vb 6
583 \&        #
584 \&        # Good Idea
585 \&        #
586 \&        while (<FILE>) {
587 \&           # ...
588 \&        }
591 instead of this:
593 .Vb 7
594 \&        #
595 \&        # Bad Idea
596 \&        #
597 \&        @data = <FILE>;
598 \&        foreach (@data) {
599 \&            # ...
600 \&        }
603 When the files you're processing are small, it doesn't much matter which
604 way you do it, but it makes a huge difference when they start getting
605 larger.
606 .IP "* Use map and grep selectively" 4
607 .IX Item "Use map and grep selectively"
608 Remember that both map and grep expect a \s-1LIST\s0 argument, so doing this:
610 .Vb 1
611 \&        @wanted = grep {/pattern/} <FILE>;
614 will cause the entire file to be slurped. For large files, it's better
615 to loop:
617 .Vb 3
618 \&        while (<FILE>) {
619 \&                push(@wanted, $_) if /pattern/;
620 \&        }
622 .IP "* Avoid unnecessary quotes and stringification" 4
623 .IX Item "Avoid unnecessary quotes and stringification"
624 Don't quote large strings unless absolutely necessary:
626 .Vb 1
627 \&        my $copy = "$large_string";
630 makes 2 copies of \f(CW$large_string\fR (one for \f(CW$copy\fR and another for the
631 quotes), whereas
633 .Vb 1
634 \&        my $copy = $large_string;
637 only makes one copy.
639 Ditto for stringifying large arrays:
641 .Vb 4
642 \&        {
643 \&                local $, = "\en";
644 \&                print @big_array;
645 \&        }
648 is much more memory-efficient than either
650 .Vb 1
651 \&        print join "\en", @big_array;
656 .Vb 4
657 \&        {
658 \&                local $" = "\en";
659 \&                print "@big_array";
660 \&        }
662 .IP "* Pass by reference" 4
663 .IX Item "Pass by reference"
664 Pass arrays and hashes by reference, not by value. For one thing, it's
665 the only way to pass multiple lists or hashes (or both) in a single
666 call/return. It also avoids creating a copy of all the contents. This
667 requires some judgment, however, because any changes will be propagated
668 back to the original data. If you really want to mangle (er, modify) a
669 copy, you'll have to sacrifice the memory needed to make one.
670 .IP "* Tie large variables to disk." 4
671 .IX Item "Tie large variables to disk."
672 For \*(L"big\*(R" data stores (i.e. ones that exceed available memory) consider
673 using one of the \s-1DB\s0 modules to store it on disk instead of in \s-1RAM\s0. This
674 will incur a penalty in access time, but that's probably better than
675 causing your hard disk to thrash due to massive swapping.
676 .Sh "把局部变量的引用返回是不安全的做法吗?"
677 .IX Subsection "Is it safe to return a reference to local or lexical data?"
678 这样是安全的,Perl的资源回收 (garbage collection)系统会解决此问题。
680 .Vb 4
681 \&    sub makeone {
682 \&        my @a = ( 1 .. 10 );
683 \&        return \e@a;
684 \&    }
687 .Vb 3
688 \&    for ( 1 .. 10 ) {
689 \&        push @many, makeone();
690 \&    }
693 .Vb 1
694 \&    print $many[4][5], "\en";
697 .Vb 1
698 \&    print "@many\en";
700 .Sh "我如何释放一个数组或散列以缩小我的程式尺寸?"
701 .IX Subsection "How can I free an array or hash so my program shrinks?"
702 你无法这麽作。系统配置给程式的记忆体是覆水难收。这也是为何执行很长一段时间的程式有时会重新执行 (re-exec)它们自己的原因。
703 Some operating systems (notably, systems that
704 use \fImmap\fR\|(2) for allocating large chunks of memory) can
705 reclaim memory that is no longer used, but on such systems,
706 perl must be configured and compiled to use the \s-1OS\s0's malloc,
707 not perl's.
709 然而,在使用你的变数时,明智地用 my()来定义执行范围,可让 Perl在脱离该范围後 将它们所占的空间释放给其它部份的程式。 (注:my()的变数也比全域变数执行起来快 10%。)当然,一个全域变数永远没有超出范围的时候,所以你无法将它占用的空间自动重新分配,不过,把它 undef() 或/和 delete()会有相同的效果。总之,在 Perl里,你并不能/应该去担心太多有关记忆体定址与解除这件事,而我们连添加这项功能(资料形态的预先定址),目前都已在进行中。
710 .Sh "如何让我的 CGI脚本 (script)执行起来更有效率?"
711 .IX Subsection "How can I make my CGI script more efficient?"
712 除了使一般 Perl程式加快或缩小的平常手段外,一个 CGI 程式还有其他的顾虑。也许它每秒会被执行好几次。每次它执行时,重新编译所花的时间、加上定址所需的 1 MB以上的系统记忆体,就是一个大杀手。光是编译成 C 是没啥帮助的 ,因为瓶颈在於整个程序开始时所负担的包袱 (start-up overhead) 。
714 最起码有两种较流行的方法可以避免这些包袱。一种解法是将 mod_perl 或是 mod_fastcgi其中一个模组加在你所执行的 Apache HTTP server。
716 有了 mod_perl 和 Apache::*模组 (从 CPAN取得),httpd执行时会带起一个内 嵌的 Perl直译器,而它会预先编译你的程式,并在不产生其它子程序的情况下用同一个定址空间来执行。Apache 扩充模组亦给 Perl一个连通 server API 的管道,所以用 Perl写的模组可以做到任何 C写的模组所具备的功能。详情请参阅 http://perl.apache.org/
718 而有了 FCGI模组 (自 CPAN取得) 和 mod_fastcgi 模块(从 http://www.fastcgi.com/取得),每个 Perl 程序将成为一个永久的 CGI 守护进程。
720 这些方法对你的系统与你撰写 CGI程式的方法都有超乎想像之外的影响,所以请小心地使用它们。
722 参见 http://www.cpan.org/modules/by\-category/15_World_Wide_Web_HTML_HTTP_CGI/ .
724 A non\-free, commercial product, ``The Velocity Engine for Perl'',
725 (http://www.binevolve.com/ or http://www.binevolve.com/velocigen/ )
726 might also be worth looking at.  It will allow you to increase the
727 performance of your Perl programs, running programs up to 25 times
728 faster than normal \s-1CGI\s0 Perl when running in persistent Perl mode or 4
729 to 5 times faster without any modification to your existing \s-1CGI\s0
730 programs. Fully functional evaluation copies are available from the
731 web site.
732 .Sh "如何隐藏 Perl程式的原始码?"
733 .IX Subsection "How can I hide the source for my Perl program?"
734 删除它。 :-) 说真的,有一些具有不同“安全”等级的方法(大部分都不能令人满意)。
736 首先,你 不能拿走读取权,不然你的程式怎麽被解译或是编译呢? (不过那也并不表示一个 CGI程式的原始码可以被使用者读取。)所以你得让档案权限停留在 0755这个友善的阶段。
738 有些人认为这是个安全上的漏洞。不过若你的程式作的是不安全的事情,光仰赖别人看不见这些漏洞、不知从何下手,那麽它依然是不安全的。其实对有些人来说他们并不需要看见程式原始码便可能判定并揭露这些不安全的部份。透过隐瞒达到的安全,就是不修正臭虫反而隐藏它们,实际上是没有安全性可言的。
740 你可以试着透过原始码过滤模组 (CPAN中的 Filter::*)来替原始码加密。但高手也许有办法将其解密还原。你也可以用下面提到的 byte code 编译器与直译器,但高手也有可能反解译它。你可以试试後面提到的原生码编译器 (native-code compiler),但高手也有可能反组译它。这些手段都需要不同难度的技巧才能让别人拿到你的原始码,但没有一种能够很确定地隐藏它。(这对每种语言来说都为真,不是只有 Perl)
742 很容易从 Perl 程序中恢复出源码。只要将程序作为 perl 解释器的参数,并且使用 B:: 中的模块就可以了。B::Deparse 模块足以恢复大多数隐藏的代码。再次的,这不是 Perl 特有的东西。
744 如果你所担心的是别人自你的程式码中获利,那麽一纸权限执照是能提供你法律上安全的唯一途径。注册你的软体并且写份权限说明,再加上一些具威胁性的句子像“这是 XYZ公司未出版的专有软体。你能撷取它并不代表你具有使用的权限...”之类云云。当然,我们不是律师,所以若你想要你的执照中每一句话在法庭上都站得住脚,就去见个律师吧。
745 .Sh "如何把我的 Perl程式码编译成 byte code或 C?"
746 .IX Subsection "How can I compile my Perl program into byte code or C?"
747 Malcolm Beattie已经写了一个多功能的後端编译器,可以从 CPAN取得,它就能做到这两项功能。它包含在 perl5.005 发布中,但是仍然是测试版。这代表着若你是个程式设计 员而非寻找万灵解药的人,那麽参与其测试就会充满趣味。
749 请了解光是编译成 C 其本身或在本质上并不能保证它就会跑得快更多。那是因为除了在运气好的状况中有一堆可以衍生成出来的原生形态外,平时的 Perl 执行系统环境依然存在因此依然会花差不多长的执行时间与占用差不多大小的记忆空间。大多数程式能省下来的不过是编译时间,这使执行速度顶多快 10-30%。有些罕见的程式能真正从中受利 (例如增快好几倍),但这还得配合原始码的微调。
751 你或许会惊讶地发现,现行版本的编译器做出来的执行档大小跟你的 Perl直译器一样大,有时更大些。那是因为依照现在的写法,所有的程式皆转成一个被 eval()的大叙述。只要建造一个动态连结的 libperl.so程式库,并将之连结起来,你就可以戏剧性地减少这 种浪费。参看 perl原始码套件中的 INSTALL pod档案以获得更详尽的讯息。如果你用这方法连结你主要的 perl执行档,就能使它变得很渺小。举例来说,在作者之一的系 统里, /usr/bin/perl只有 11k“小”而已!
753 In general, the compiler will do nothing to make a Perl program smaller,
754 faster, more portable, or more secure.  In fact, it can make your
755 situation worse.  The executable will be bigger, your \s-1VM\s0 system may take
756 longer to load the whole thing, the binary is fragile and hard to fix,
757 and compilation never stopped software piracy in the form of crackers,
758 viruses, or bootleggers.  The real advantage of the compiler is merely
759 packaging, and once you see the size of what it makes (well, unless
760 you use a shared \fIlibperl.so\fR), you'll probably want a complete
761 Perl install anyway.
762 .Sh "How can I compile Perl into Java?"
763 .IX Subsection "How can I compile Perl into Java?"
764 You can also integrate Java and Perl with the
765 Perl Resource Kit from O'Reilly and Associates.  See
766 http://www.oreilly.com/catalog/prkunix/ .
768 Perl 5.6 comes with Java Perl Lingo, or \s-1JPL\s0.  \s-1JPL\s0, still in
769 development, allows Perl code to be called from Java.  See jpl/README
770 in the Perl source tree.
771 .ie n .Sh "如何才能让 "#!perl" 在 [MS-DOS,NT,...] 下起作用?"
772 .el .Sh "如何才能让 "#!perl" 在 [MS-DOS,NT,...] 下起作用?"
773 .IX Subsection "How can I get #!perl to work on [MS-DOS,NT,...]?"
774 OS/2下只要用:
776 .Vb 1
777 \&    extproc perl -S -your_switches
780 当作 \f(CW\*(C`*.cmd\*(C'\fR 档案的第一行 (\f(CW\*(C`\-S\*(C'\fR 是因 cmd.exe中其 `extproc'处理的臭虫才要的)。DOS使用者应先制作一个相对的 batch 档案然後将它以 ALTERNATIVE_SHEBANG 的方式写成程式。(更多讯息在原始码版本的 INSTALL档案里)
782 The Win95/NT installation, when using the ActiveState port of Perl,
783 will modify the Registry to associate the \f(CW\*(C`.pl\*(C'\fR extension with the
784 perl interpreter.  If you install another port, perhaps even building
785 your own Win95/NT Perl from the standard sources by using a Windows port
786 of gcc (e.g., with cygwin or mingw32), then you'll have to modify
787 the Registry yourself.  In addition to associating \f(CW\*(C`.pl\*(C'\fR with the
788 interpreter, \s-1NT\s0 people can use: \f(CW\*(C`SET PATHEXT=%PATHEXT%;.PL\*(C'\fR to let them
789 run the program \f(CW\*(C`install\-linux.pl\*(C'\fR merely by typing \f(CW\*(C`install\-linux\*(C'\fR.
791 麦金塔的 perl程式将会有适当的创造者与形态 (Creator and Type),所以双击它们就会执行这些 perl 应用程式。
793 重要:不论你做什麽,请千万不要因为觉得沮丧,就把 perl 直译器丢到你的 cgi-bin目录下,好让你的 web 伺服器能执行你的程式。这是一个非常大的安全漏洞。花点时间想想怎样才是正确的做法吧。
794 .Sh "我能利用命令行写出有用的程式吗?"
795 .IX Subsection "Can I write useful Perl programs on the command line?"
796 可以。详情请看 perlrun。以下有些范例 (假设用的是标准的 Unix shell引言规则)。
798 .Vb 2
799 \&    # 把第一栏和最後一栏相加
800 \&    perl -lane 'print $F[0] + $F[-1]' *
803 .Vb 2
804 \&    # 辨别是否为文字档
805 \&    perl -le 'for(@ARGV) {print if -f && -T _}' *
808 .Vb 2
809 \&    # 移除 C程式中的说明
810 \&    perl -0777 -pe 's{/\e*.*?\e*/}{}gs' foo.c
813 .Vb 2
814 \&    # 让档案年轻一个月,躲避 reaper daemons
815 \&    perl -e '$X=24*60*60; utime(time(),time() + 30 * $X,@ARGV)' *
818 .Vb 2
819 \&    # 找出第一个未用的 uid
820 \&    perl -le '$i++ while getpwuid($i); print $i'
823 .Vb 3
824 \&    # 显示合理的使用说明路径 (manpath)
825 \&    echo $PATH | perl -nl -072 -e '
826 \&        s![^/+]*$!man!&&-d&&!$s{$_}++&&push@m,$_;END{print"@m"}'
829 好吧,最後一个例子事实上是「perl程式困惑化」竞赛 (Obfuscated Perl)的 参赛作品。 :-)
830 .Sh "为何一行的 perl 程式无法在我的 DOS/Mac/VMS系统上运作?"
831 .IX Subsection "Why don't Perl one-liners work on my DOS/Mac/VMS system?"
832 问题通常出在那些系统的命令解译器对於参数的引用与 Unix shells 所作的解释不同,而後者很不幸的是这些一行 perl 的生父。在某些系统,也许你得把单引号改成双引号,但这却是你万万 不可在 Unix或 Plan9系统上作的事。你也许还得把一个 %改成 %%。
834 例如:
836 .Vb 2
837 \&    # Unix
838 \&    perl -e 'print "Hello world\en"'
841 .Vb 2
842 \&    # DOS 和其他机器
843 \&    perl -e "print \e"Hello world\en\e""
846 .Vb 3
847 \&    # Mac
848 \&    print "Hello world\en"
849 \&     (然后运行 "Myscript" 或按 Shift-Command-R)
852 .Vb 2
853 \&    # MPW
854 \&    perl -e 'print "Hello world\en"'
857 .Vb 2
858 \&    # VMS
859 \&    perl -e "print ""Hello world\en"""
862 问题是,这些方法没有一个是完全可靠的:它都得看命令解译器的脸色。在 Unix中,前两者通常可以用。在 DOS下,两者可能都没有用。若 4DOS是命令解译器,下面此法可能比 较有希望:
864 .Vb 1
865 \&  perl -e "print <Ctrl-x>"Hello world\en<Ctrl-x>""
868 在 Mac 下,端视你所用的环境为何。 MacPerl所附的 shell,或是 MPW, 其所支援的参数格式有不少都蛮像 Unix shells的,除了它自在地使用 Mac 的非 ASCII字元当成控制字元。
870 Using \fIqq()\fR, q(), and \fIqx()\fR, instead of \*(L"double quotes\*(R", 'single
871 quotes', and `backticks`, may make one-liners easier to write.
873 恐怕我得说这问题并没有一般解。白话一点说,它真是一团乱。
875 [部份答案是由 Kenneth Albanowski 所提供的。]
876 .Sh "我得去哪里学 Perl的 CGI或是 Web程式设计呢?"
877 .IX Subsection "Where can I learn about CGI or Web programming in Perl?"
878 就模组来说,去 CPAN抓 CGI 和 LWP 两个模组。就书本来看,参考关於书那部份里特别和 web 相关的问题。若有与 web相关的疑难杂症,像“为何我收到 500错误”或“它在命令列模式下跑得好好的,怎麽不能在浏览器下正常执行”时,请参看:
880 .Vb 1
881 \&        http://www.perl.org/CGI_MetaFAQ.html
883 .Sh "从哪里可以学习面向对象的 Perl 编程?"
884 .IX Subsection "Where can I learn about object-oriented Perl programming?"
885 perltoot是个好开始,然後你可以再参考 perlobj 和 perlboot,Perltoot,perltooc 以及 perlbot (如果你使用老版本的 Perl,你可能没有这些。去 http://www.perldoc.com/ 下载吧,但是首先考虑一下升级你的 perl)
887 有本好书关于 Perl 中的 \s-1OO\s0 是 \*(L"Object\-Oriented Perl\*(R"
888 作者是 Damian Conway ,出版社为 Manning Publications,
889 http://www.manning.com/Conway/index.html
890 .Sh "从哪里可以学习将 Perl 与 C 连接?[h2xs, xsubpp]"
891 .IX Subsection "Where can I learn about linking C with Perl? [h2xs, xsubpp]"
892 若你要从 Perl程式呼叫 C,就自 perlxstut开始向 perlxs ,xsubpp ,及 perlguts前进。反之,则读 perlembed ,perlcall ,及 perlguts 。别忘了你可以从各模组的作者如何写他们的模组及解决他们的问题中学到很多。
893 .Sh "我已经阅读了 perlembed,perlguts 等等,但是还是不能在我的 C 程序中嵌入 perl;我作错了什么?"
894 .IX Subsection "I've read perlembed, perlguts, etc., but I can't embed perl in my C program; what am I doing wrong?"
895 自 CPAN 下载 ExtUtils::Embed 套件,然後执行 `make test'。如果测试成功,就一遍又一遍地读那些 pod 说明档案。若它失败了,参看 perlbug并送一份内有 \f(CW\*(C`make test TEST_VERBOSE=1\*(C'\fR 与 \f(CW\*(C`perl \-V\*(C'\fR 输出的报告。
896 .Sh "我试着运行我的脚本时,看到了这样的消息。它是什么意思?"
897 .IX Subsection "When I tried to run my script, I got this message. What does it mean?"
898 perldiag有一份完整的 perl错误与警告讯息列表,并附有说明文字。你也可以用 splain程式 (伴随 perl而来)去解释这些错误讯息:
900 .Vb 2
901 \&    perl program 2>diag.out
902 \&    splain [-v] [-p] diag.out
905 更改你的程式让它替你解释这些讯息也可以:
907 .Vb 1
908 \&    use diagnostics;
913 .Vb 1
914 \&    use diagnostics -verbose;
916 .Sh "什麽是 What's MakeMaker?"
917 .IX Subsection "What's MakeMaker?"
918 此模组 (亦为标准 perl 套件之一部份)设计的目的是要替一个模组从一个 Makefile.PL 中自动撰写出一个 Makefile。详情请看 ExtUtils::MakeMaker。
919 .SH "AUTHOR AND COPYRIGHT"
920 .IX Header "AUTHOR AND COPYRIGHT"
921 Copyright (c) 1997\-2002 Tom Christiansen and Nathan Torkington.
922 All rights reserved.
924 This documentation is free; you can redistribute it and/or modify it
925 under the same terms as Perl itself.
927 Irrespective of its distribution, all code examples here are in the public
928 domain.  You are permitted and encouraged to use this code and any
929 derivatives thereof in your own programs for fun or for profit as you
930 see fit.  A simple comment in the code giving credit to the \s-1FAQ\s0 would
931 be courteous but is not required.
932 .SH "译者"
933 陈彦铭,萧百龄,两只老虎工作室