version 2 showing authors affecting page license.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
PERLFAQ3 |
|
|
2 |
!!!PERLFAQ3 |
|
|
3 |
NAME |
|
|
4 |
DESCRIPTION |
|
|
5 |
AUTHOR AND COPYRIGHT |
|
|
6 |
---- |
|
|
7 |
!!NAME |
|
|
8 |
|
|
|
9 |
|
|
|
10 |
perlfaq3 - Programming Tools ($Revision: 1.38 $, $Date: 1999/05/23 16:08:30 $) |
|
|
11 |
!!DESCRIPTION |
|
|
12 |
|
|
|
13 |
|
|
|
14 |
This section of the FAQ answers questions |
|
|
15 |
related to programmer tools and programming |
|
|
16 |
support. |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
__How do I do (anything)?__ |
|
|
20 |
|
|
|
21 |
|
|
|
22 |
Have you looked at CPAN (see perlfaq2)? The |
|
|
23 |
chances are that someone has already written a module that |
|
|
24 |
can solve your problem. Have you read the appropriate man |
|
|
25 |
pages? Here's a brief index: |
|
|
26 |
|
|
|
27 |
|
|
|
28 |
Basics perldata, perlvar, perlsyn, perlop, perlsub |
|
|
29 |
Execution perlrun, perldebug |
|
|
30 |
Functions perlfunc |
|
|
31 |
Objects perlref, perlmod, perlobj, perltie |
|
|
32 |
Data Structures perlref, perllol, perldsc |
|
|
33 |
Modules perlmod, perlmodlib, perlsub |
|
|
34 |
Regexes perlre, perlfunc, perlop, perllocale |
|
|
35 |
Moving to perl5 perltrap, perl |
|
|
36 |
Linking w/C perlxstut, perlxs, perlcall, perlguts, perlembed |
|
|
37 |
Various http://www.perl.com/CPAN/doc/FMTEYEWTK/index.html |
|
|
38 |
(not a man-page but still useful) |
|
|
39 |
A crude table of contents for the Perl man page set is found in perltoc. |
|
|
40 |
|
|
|
41 |
|
|
|
42 |
__How can I use Perl interactively?__ |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
The typical approach uses the Perl debugger, described in |
|
|
46 |
the perldebug(1) man page, on an ``empty'' program, |
|
|
47 |
like this: |
|
|
48 |
|
|
|
49 |
|
|
|
50 |
perl -de 42 |
|
|
51 |
Now just type in any legal Perl code, and it will be immediately evaluated. You can also examine the symbol table, get stack backtraces, check variable values, set breakpoints, and other operations typically found in symbolic debuggers. |
|
|
52 |
|
|
|
53 |
|
|
|
54 |
__Is there a Perl shell?__ |
|
|
55 |
|
|
|
56 |
|
|
|
57 |
In general, no. The Shell.pm module (distributed with Perl) |
|
|
58 |
makes Perl try commands which aren't part of the Perl |
|
|
59 |
language as shell commands. perlsh from the source |
|
|
60 |
distribution is simplistic and uninteresting, but may still |
|
|
61 |
be what you want. |
|
|
62 |
|
|
|
63 |
|
|
|
64 |
__How do I debug my Perl programs?__ |
|
|
65 |
|
|
|
66 |
|
|
|
67 |
Have you tried use warnings or used -w? |
|
|
68 |
They enable warnings to detect dubious |
|
|
69 |
practices. |
|
|
70 |
|
|
|
71 |
|
|
|
72 |
Have you tried use strict? It prevents you from |
|
|
73 |
using symbolic references, makes you predeclare any |
|
|
74 |
subroutines that you call as bare words, and (probably most |
|
|
75 |
importantly) forces you to predeclare your variables with |
|
|
76 |
my, our, or use |
|
|
77 |
vars. |
|
|
78 |
|
|
|
79 |
|
|
|
80 |
Did you check the return values of each and every system |
|
|
81 |
call? The operating system (and thus Perl) tells you whether |
|
|
82 |
they worked, and if not why. |
|
|
83 |
|
|
|
84 |
|
|
|
85 |
open(FH, |
|
|
86 |
Did you read perltrap? It's full of gotchas for old and new Perl programmers and even has sections for those of you who are upgrading from languages like ''awk'' and ''C''. |
|
|
87 |
|
|
|
88 |
|
|
|
89 |
Have you tried the Perl debugger, described in perldebug? |
|
|
90 |
You can step through your program and see what it's doing |
|
|
91 |
and thus work out why what it's doing isn't what it should |
|
|
92 |
be doing. |
|
|
93 |
|
|
|
94 |
|
|
|
95 |
__How do I profile my Perl programs?__ |
|
|
96 |
|
|
|
97 |
|
|
|
98 |
You should get the Devel::DProf module from the standard |
|
|
99 |
distribution (or separately on CPAN ) and |
|
|
100 |
also use Benchmark.pm from the standard distribution. The |
|
|
101 |
Benchmark module lets you time specific portions of your |
|
|
102 |
code, while Devel::DProf gives detailed breakdowns of where |
|
|
103 |
your code spends its time. |
|
|
104 |
|
|
|
105 |
|
|
|
106 |
Here's a sample use of Benchmark: |
|
|
107 |
|
|
|
108 |
|
|
|
109 |
use Benchmark; |
|
|
110 |
@junk = `cat /etc/motd`; |
|
|
111 |
$count = 10_000; |
|
|
112 |
timethese($count, { |
|
|
113 |
'map' = |
|
|
114 |
This is what it prints (on one machine--your results will be dependent on your hardware, operating system, and the load on your machine): |
|
|
115 |
|
|
|
116 |
|
|
|
117 |
Benchmark: timing 10000 iterations of for, map... |
|
|
118 |
for: 4 secs ( 3.97 usr 0.01 sys = 3.98 cpu) |
|
|
119 |
map: 6 secs ( 4.97 usr 0.00 sys = 4.97 cpu) |
|
|
120 |
Be aware that a good benchmark is very hard to write. It only tests the data you give it and proves little about the differing complexities of contrasting algorithms. |
|
|
121 |
|
|
|
122 |
|
|
|
123 |
__How do I cross-reference my Perl |
|
|
124 |
programs?__ |
|
|
125 |
|
|
|
126 |
|
|
|
127 |
The B::Xref module, shipped with the new, alpha-release Perl |
|
|
128 |
compiler (not the general distribution prior to the 5.005 |
|
|
129 |
release), can be used to generate cross-reference reports |
|
|
130 |
for Perl programs. |
|
|
131 |
|
|
|
132 |
|
|
|
133 |
perl -MO=Xref[[,OPTIONS] scriptname.plx |
|
|
134 |
|
|
|
135 |
|
|
|
136 |
__Is there a pretty-printer (formatter) for |
|
|
137 |
Perl?__ |
|
|
138 |
|
|
|
139 |
|
|
|
140 |
There is no program that will reformat Perl as much as |
|
|
141 |
indent(1) does for C. The complex feedback between |
|
|
142 |
the scanner and the parser (this feedback is what confuses |
|
|
143 |
the vgrind and emacs programs) makes it challenging at best |
|
|
144 |
to write a stand-alone Perl parser. |
|
|
145 |
|
|
|
146 |
|
|
|
147 |
Of course, if you simply follow the guidelines in perlstyle, |
|
|
148 |
you shouldn't need to reformat. The habit of formatting your |
|
|
149 |
code as you write it will help prevent bugs. Your editor can |
|
|
150 |
and should help you with this. The perl-mode or newer |
|
|
151 |
cperl-mode for emacs can provide remarkable amounts of help |
|
|
152 |
with most (but not all) code, and even less programmable |
|
|
153 |
editors can provide significant assistance. Tom swears by |
|
|
154 |
the following settings in vi and its clones: |
|
|
155 |
|
|
|
156 |
|
|
|
157 |
set ai sw=4 |
|
|
158 |
map! ^O {^M}^[[O^T |
|
|
159 |
Now put that in your ''.exrc'' file (replacing the caret characters with control characters) and away you go. In insert mode, ^T is for indenting, ^D is for undenting, and ^O is for blockdenting-- as it were. If you haven't used the last one, you're missing a lot. A more complete example, with comments, can be found at http://www.perl.com/CPAN-local/authors/id/TOMC/scripts/toms.exrc.gz |
|
|
160 |
|
|
|
161 |
|
|
|
162 |
If you are used to using the ''vgrind'' program for |
|
|
163 |
printing out nice code to a laser printer, you can take a |
|
|
164 |
stab at this using |
|
|
165 |
http://www.perl.com/CPAN/doc/misc/tips/working.vgrind.entry, |
|
|
166 |
but the results are not particularly satisfying for |
|
|
167 |
sophisticated code. |
|
|
168 |
|
|
|
169 |
|
|
|
170 |
The a2ps at http://www.infres.enst.fr/%7Edemaille/a2ps/ does |
|
|
171 |
lots of things related to generating nicely printed output |
|
|
172 |
of documents. |
|
|
173 |
|
|
|
174 |
|
|
|
175 |
__Is there a ctags for Perl?__ |
|
|
176 |
|
|
|
177 |
|
|
|
178 |
There's a simple one at |
|
|
179 |
http://www.perl.com/CPAN/authors/id/TOMC/scripts/ptags.gz |
|
|
180 |
which may do the trick. And if not, it's easy to hack into |
|
|
181 |
what you want. |
|
|
182 |
|
|
|
183 |
|
|
|
184 |
__Is there an IDE or Windows Perl |
|
|
185 |
Editor?__ |
|
|
186 |
|
|
|
187 |
|
|
|
188 |
Perl programs are just plain text, so any editor will |
|
|
189 |
do. |
|
|
190 |
|
|
|
191 |
|
|
|
192 |
If you're on Unix, you already have an IDE--Unix itself. The |
|
|
193 |
UNIX philosophy is the philosophy of several |
|
|
194 |
small tools that each do one thing and do it well. It's like |
|
|
195 |
a carpenter's toolbox. |
|
|
196 |
|
|
|
197 |
|
|
|
198 |
If you want a Windows IDE , check the |
|
|
199 |
following: |
|
|
200 |
|
|
|
201 |
|
|
|
202 |
CodeMagicCD |
|
|
203 |
|
|
|
204 |
|
|
|
205 |
http://www.codemagiccd.com/ |
|
|
206 |
|
|
|
207 |
|
|
|
208 |
Komodo |
|
|
209 |
|
|
|
210 |
|
|
|
211 |
!ActiveState's cross-platform, multi-language |
|
|
212 |
IDE has Perl support, including a regular |
|
|
213 |
expression debugger and remote debugging |
|
|
214 |
(http://www.!ActiveState.com/Products/Komodo/index.html). |
|
|
215 |
(Visual Perl, a Visual Studio.NET plug-in is currently |
|
|
216 |
(early 2001) in beta |
|
|
217 |
(http://www.!ActiveState.com/Products/!VisualPerl/index.html)). |
|
|
218 |
|
|
|
219 |
|
|
|
220 |
The Object System |
|
|
221 |
|
|
|
222 |
|
|
|
223 |
(http://www.castlelink.co.uk/object_system/) is a Perl web |
|
|
224 |
applications development IDE . |
|
|
225 |
|
|
|
226 |
|
|
|
227 |
!PerlBuilder |
|
|
228 |
|
|
|
229 |
|
|
|
230 |
(http://www.solutionsoft.com/perl.htm) is an integrated |
|
|
231 |
development environment for Windows that supports Perl |
|
|
232 |
development. |
|
|
233 |
|
|
|
234 |
|
|
|
235 |
Perl code magic |
|
|
236 |
|
|
|
237 |
|
|
|
238 |
(http://www.petes-place.com/codemagic.html). |
|
|
239 |
|
|
|
240 |
|
|
|
241 |
visiPerl+ |
|
|
242 |
|
|
|
243 |
|
|
|
244 |
http://helpconsulting.net/visiperl/, from Help |
|
|
245 |
Consulting. |
|
|
246 |
|
|
|
247 |
|
|
|
248 |
For editors: if you're on Unix you probably have vi or a vi |
|
|
249 |
clone already, and possibly an emacs too, so you may not |
|
|
250 |
need to download anything. In any emacs the cperl-mode (M-x |
|
|
251 |
cperl-mode) gives you perhaps the best available Perl |
|
|
252 |
editing mode in any editor. |
|
|
253 |
|
|
|
254 |
|
|
|
255 |
For Windows editors: you can download an Emacs |
|
|
256 |
|
|
|
257 |
|
|
|
258 |
GNU Emacs |
|
|
259 |
|
|
|
260 |
|
|
|
261 |
http://www.gnu.org/software/emacs/windows/ntemacs.html |
|
|
262 |
|
|
|
263 |
|
|
|
264 |
MicroEMACS |
|
|
265 |
|
|
|
266 |
|
|
|
267 |
http://members.nbci.com/uemacs/ |
|
|
268 |
|
|
|
269 |
|
|
|
270 |
XEmacs |
|
|
271 |
|
|
|
272 |
|
|
|
273 |
http://www.xemacs.org/Download/index.html |
|
|
274 |
|
|
|
275 |
|
|
|
276 |
or a vi clone such as |
|
|
277 |
|
|
|
278 |
|
|
|
279 |
Elvis |
|
|
280 |
|
|
|
281 |
|
|
|
282 |
ftp://ftp.cs.pdx.edu/pub/elvis/ |
|
|
283 |
http://www.fh-wedel.de/elvis/ |
|
|
284 |
|
|
|
285 |
|
|
|
286 |
Vile |
|
|
287 |
|
|
|
288 |
|
|
|
289 |
http://vile.cx/ |
|
|
290 |
|
|
|
291 |
|
|
|
292 |
Vim |
|
|
293 |
|
|
|
294 |
|
|
|
295 |
http://www.vim.org/ |
|
|
296 |
|
|
|
297 |
|
|
|
298 |
win32: http://www.cs.vu.nl/%7Etmgil/vi.html |
|
|
299 |
|
|
|
300 |
|
|
|
301 |
For vi lovers in general, Windows or elsewhere: |
|
|
302 |
http://www.thomer.com/thomer/vi/vi.html. |
|
|
303 |
|
|
|
304 |
|
|
|
305 |
nvi (http://www.bostic.com/vi/, available from |
|
|
306 |
CPAN in src/misc/) is yet another vi clone, |
|
|
307 |
unfortunately not available for Windows, but in |
|
|
308 |
UNIX platforms you might be interested in |
|
|
309 |
trying it out, firstly because strictly speaking it is not a |
|
|
310 |
vi clone, it is the real vi, or the new incarnation of it, |
|
|
311 |
and secondly because you can embed Perl inside it to use |
|
|
312 |
Perl as the scripting language. nvi is not alone in this, |
|
|
313 |
though: at least also vim and vile offer an embedded |
|
|
314 |
Perl. |
|
|
315 |
|
|
|
316 |
|
|
|
317 |
The following are Win32 multilanguage editor/IDESs that |
|
|
318 |
support Perl: |
|
|
319 |
|
|
|
320 |
|
|
|
321 |
Codewright |
|
|
322 |
|
|
|
323 |
|
|
|
324 |
http://www.starbase.com/ |
|
|
325 |
|
|
|
326 |
|
|
|
327 |
!MultiEdit |
|
|
328 |
|
|
|
329 |
|
|
|
330 |
http://www.!MultiEdit.com/ |
|
|
331 |
|
|
|
332 |
|
|
|
333 |
!SlickEdit |
|
|
334 |
|
|
|
335 |
|
|
|
336 |
http://www.slickedit.com/ |
|
|
337 |
|
|
|
338 |
|
|
|
339 |
There is also a toyedit Text widget based editor written in |
|
|
340 |
Perl that is distributed with the Tk module on |
|
|
341 |
CPAN . The ptkdb |
|
|
342 |
(http://world.std.com/~aep/ptkdb/) is a Perl/tk based |
|
|
343 |
debugger that acts as a development environment of sorts. |
|
|
344 |
Perl Composer |
|
|
345 |
(http://perlcomposer.sourceforge.net/vperl.html) is an |
|
|
346 |
IDE for Perl/Tk GUI |
|
|
347 |
creation. |
|
|
348 |
|
|
|
349 |
|
|
|
350 |
In addition to an editor/IDE you might be interested in a |
|
|
351 |
more powerful shell environment for Win32. Your options |
|
|
352 |
include |
|
|
353 |
|
|
|
354 |
|
|
|
355 |
Bash |
|
|
356 |
|
|
|
357 |
|
|
|
358 |
from the Cygwin package |
|
|
359 |
(http://sources.redhat.com/cygwin/) |
|
|
360 |
|
|
|
361 |
|
|
|
362 |
Ksh |
|
|
363 |
|
|
|
364 |
|
|
|
365 |
from the MKS Toolkit (http://www.mks.com/), |
|
|
366 |
or the Bourne shell of the U/WIN environment |
|
|
367 |
(http://www.research.att.com/sw/tools/uwin/) |
|
|
368 |
|
|
|
369 |
|
|
|
370 |
Tcsh |
|
|
371 |
|
|
|
372 |
|
|
|
373 |
ftp://ftp.astron.com/pub/tcsh/, see also |
|
|
374 |
http://www.primate.wisc.edu/software/csh-tcsh-book/ |
|
|
375 |
|
|
|
376 |
|
|
|
377 |
Zsh |
|
|
378 |
|
|
|
379 |
|
|
|
380 |
ftp://ftp.blarg.net/users/amol/zsh/, see also |
|
|
381 |
http://www.zsh.org/ |
|
|
382 |
|
|
|
383 |
|
|
|
384 |
MKS and U/WIN are commercial (U/WIN is free |
|
|
385 |
for educational and research purposes), Cygwin is covered by |
|
|
386 |
the GNU Public License (but that shouldn't |
|
|
387 |
matter for Perl use). The Cygwin, MKS , and |
|
|
388 |
U/WIN all contain (in addition to the shells) a |
|
|
389 |
comprehensive set of standard UNIX toolkit |
|
|
390 |
utilities. |
|
|
391 |
|
|
|
392 |
|
|
|
393 |
If you're transferring text files between Unix and Windows |
|
|
394 |
using FTP be sure to transfer them in |
|
|
395 |
ASCII mode so the ends of lines are |
|
|
396 |
appropriately converted. |
|
|
397 |
|
|
|
398 |
|
|
|
399 |
On Mac OS the !MacPerl Application comes with |
|
|
400 |
a simple 32k text editor that behaves like a rudimentary |
|
|
401 |
IDE . In contrast to the !MacPerl Application |
|
|
402 |
the MPW Perl tool can make use of the |
|
|
403 |
MPW Shell itself as an editor (with no 32k |
|
|
404 |
limit). |
|
|
405 |
|
|
|
406 |
|
|
|
407 |
BBEdit and BBEdit Lite |
|
|
408 |
|
|
|
409 |
|
|
|
410 |
are text editors for Mac OS that have a Perl |
|
|
411 |
sensitivity mode (http://web.barebones.com/). |
|
|
412 |
|
|
|
413 |
|
|
|
414 |
Alpha |
|
|
415 |
|
|
|
416 |
|
|
|
417 |
is an editor, written and extensible in Tcl, that |
|
|
418 |
nonetheless has built in support for several popular markup |
|
|
419 |
and programming languages including Perl and |
|
|
420 |
HTML (http://alpha.olm.net/). |
|
|
421 |
|
|
|
422 |
|
|
|
423 |
Pepper and Pe are programming language sensitive text |
|
|
424 |
editors for Mac OS X and BeOS respectively |
|
|
425 |
(http://www.hekkelman.com/). |
|
|
426 |
|
|
|
427 |
|
|
|
428 |
__Where can I get Perl macros for vi?__ |
|
|
429 |
|
|
|
430 |
|
|
|
431 |
For a complete version of Tom Christiansen's vi |
|
|
432 |
configuration file, see |
|
|
433 |
http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/toms.exrc.gz |
|
|
434 |
, the standard benchmark file for vi emulators. The file |
|
|
435 |
runs best with nvi, the current version of vi out of |
|
|
436 |
Berkeley, which incidentally can be built with an embedded |
|
|
437 |
Perl interpreter--see |
|
|
438 |
http://www.perl.com/CPAN/src/misc. |
|
|
439 |
|
|
|
440 |
|
|
|
441 |
__Where can I get perl-mode for emacs?__ |
|
|
442 |
|
|
|
443 |
|
|
|
444 |
Since Emacs version 19 patchlevel 22 or so, there have been |
|
|
445 |
both a perl-mode.el and support for the Perl debugger built |
|
|
446 |
in. These should come with the standard Emacs 19 |
|
|
447 |
distribution. |
|
|
448 |
|
|
|
449 |
|
|
|
450 |
In the Perl source directory, you'll find a directory called |
|
|
451 |
``emacs'', which contains a cperl-mode that color-codes |
|
|
452 |
keywords, provides context-sensitive help, and other nifty |
|
|
453 |
things. |
|
|
454 |
|
|
|
455 |
|
|
|
456 |
Note that the perl-mode of emacs will have fits with |
|
|
457 |
(single quote), and mess up |
|
|
458 |
the indentation and highlighting. You are probably using |
|
|
459 |
in new Perl code anyway, so |
|
|
460 |
this shouldn't be an issue. |
|
|
461 |
|
|
|
462 |
|
|
|
463 |
__How can I use curses with Perl?__ |
|
|
464 |
|
|
|
465 |
|
|
|
466 |
The Curses module from CPAN provides a |
|
|
467 |
dynamically loadable object module interface to a curses |
|
|
468 |
library. A small demo can be found at the directory |
|
|
469 |
http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/rep; |
|
|
470 |
this program repeats a command and updates the screen as |
|
|
471 |
needed, rendering __rep ps axu__ similar to |
|
|
472 |
__top__. |
|
|
473 |
|
|
|
474 |
|
|
|
475 |
__How can I use X or Tk with Perl?__ |
|
|
476 |
|
|
|
477 |
|
|
|
478 |
Tk is a completely Perl-based, object-oriented interface to |
|
|
479 |
the Tk toolkit that doesn't force you to use Tcl just to get |
|
|
480 |
at Tk. Sx is an interface to the Athena Widget set. Both are |
|
|
481 |
available from CPAN . See the directory |
|
|
482 |
http://www.perl.com/CPAN/modules/by-category/08_User_Interfaces/ |
|
|
483 |
|
|
|
484 |
|
|
|
485 |
Invaluable for Perl/Tk programming are the Perl/Tk |
|
|
486 |
FAQ at |
|
|
487 |
http://w4.lns.cornell.edu/%7Epvhp/ptk/ptkTOC.html , the |
|
|
488 |
Perl/Tk Reference Guide available at |
|
|
489 |
http://www.perl.com/CPAN-local/authors/Stephen_O_Lidie/ , |
|
|
490 |
and the online manpages at |
|
|
491 |
http://www-users.cs.umn.edu/%7Eamundson/perl/perltk/toc.html |
|
|
492 |
. |
|
|
493 |
|
|
|
494 |
|
|
|
495 |
__How can I generate simple menus without using |
|
|
496 |
CGI or Tk?__ |
|
|
497 |
|
|
|
498 |
|
|
|
499 |
The |
|
|
500 |
http://www.perl.com/CPAN/authors/id/SKUNZ/perlmenu.v4.0.tar.gz |
|
|
501 |
module, which is curses-based, can help with |
|
|
502 |
this. |
|
|
503 |
|
|
|
504 |
|
|
|
505 |
__What is undump?__ |
|
|
506 |
|
|
|
507 |
|
|
|
508 |
See the next question on ``How can I make my Perl program |
|
|
509 |
run faster?'' |
|
|
510 |
|
|
|
511 |
|
|
|
512 |
__How can I make my Perl program run |
|
|
513 |
faster?__ |
|
|
514 |
|
|
|
515 |
|
|
|
516 |
The best way to do this is to come up with a better |
|
|
517 |
algorithm. This can often make a dramatic difference. Jon |
|
|
518 |
Bentley's book ``Programming Pearls'' (that's not a |
|
|
519 |
misspelling!) has some good tips on optimization, too. |
|
|
520 |
Advice on benchmarking boils down to: benchmark and profile |
|
|
521 |
to make sure you're optimizing the right part, look for |
|
|
522 |
better algorithms instead of microtuning your code, and when |
|
|
523 |
all else fails consider just buying faster |
|
|
524 |
hardware. |
|
|
525 |
|
|
|
526 |
|
|
|
527 |
A different approach is to autoload seldom-used Perl code. |
|
|
528 |
See the !AutoSplit and !AutoLoader modules in the standard |
|
|
529 |
distribution for that. Or you could locate the bottleneck |
|
|
530 |
and think about writing just that part in C, the way we used |
|
|
531 |
to take bottlenecks in C code and write them in assembler. |
|
|
532 |
Similar to rewriting in C, modules that have critical |
|
|
533 |
sections can be written in C (for instance, the |
|
|
534 |
PDL module from CPAN |
|
|
535 |
). |
|
|
536 |
|
|
|
537 |
|
|
|
538 |
In some cases, it may be worth it to use the backend |
|
|
539 |
compiler to produce byte code (saving compilation time) or |
|
|
540 |
compile into C, which will certainly save compilation time |
|
|
541 |
and sometimes a small amount (but not much) execution time. |
|
|
542 |
See the question about compiling your Perl programs for more |
|
|
543 |
on the compiler--the wins aren't as obvious as you'd |
|
|
544 |
hope. |
|
|
545 |
|
|
|
546 |
|
|
|
547 |
If you're currently linking your perl executable to a shared |
|
|
548 |
''libc.so'', you can often gain a 10-25% performance |
|
|
549 |
benefit by rebuilding it to link with a static libc.a |
|
|
550 |
instead. This will make a bigger perl executable, but your |
|
|
551 |
Perl programs (and programmers) may thank you for it. See |
|
|
552 |
the ''INSTALL'' file in the source |
|
|
553 |
distribution for more information. |
|
|
554 |
|
|
|
555 |
|
|
|
556 |
Unsubstantiated reports allege that Perl interpreters that |
|
|
557 |
use sfio outperform those that don't (for I/O intensive |
|
|
558 |
applications). To try this, see the |
|
|
559 |
''INSTALL'' file in the source |
|
|
560 |
distribution, especially the ``Selecting File I/O |
|
|
561 |
mechanisms'' section. |
|
|
562 |
|
|
|
563 |
|
|
|
564 |
The undump program was an old attempt to speed up your Perl |
|
|
565 |
program by storing the already-compiled form to disk. This |
|
|
566 |
is no longer a viable option, as it only worked on a few |
|
|
567 |
architectures, and wasn't a good solution |
|
|
568 |
anyway. |
|
|
569 |
|
|
|
570 |
|
|
|
571 |
__How can I make my Perl program take less |
|
|
572 |
memory?__ |
|
|
573 |
|
|
|
574 |
|
|
|
575 |
When it comes to time-space tradeoffs, Perl nearly always |
|
|
576 |
prefers to throw memory at a problem. Scalars in Perl use |
|
|
577 |
more memory than strings in C, arrays take more than that, |
|
|
578 |
and hashes use even more. While there's still a lot to be |
|
|
579 |
done, recent releases have been addressing these issues. For |
|
|
580 |
example, as of 5.004, duplicate hash keys are shared amongst |
|
|
581 |
all hashes using them, so require no |
|
|
582 |
reallocation. |
|
|
583 |
|
|
|
584 |
|
|
|
585 |
In some cases, using ''substr()'' or ''vec()'' to |
|
|
586 |
simulate arrays can be highly beneficial. For example, an |
|
|
587 |
array of a thousand booleans will take at least 20,000 bytes |
|
|
588 |
of space, but it can be turned into one 125-byte bit |
|
|
589 |
vector--a considerable memory savings. The standard |
|
|
590 |
Tie::!SubstrHash module can also help for certain types of |
|
|
591 |
data structure. If you're working with specialist data |
|
|
592 |
structures (matrices, for instance) modules that implement |
|
|
593 |
these in C may use less memory than equivalent Perl |
|
|
594 |
modules. |
|
|
595 |
|
|
|
596 |
|
|
|
597 |
Another thing to try is learning whether your Perl was |
|
|
598 |
compiled with the system malloc or with Perl's builtin |
|
|
599 |
malloc. Whichever one it is, try using the other one and see |
|
|
600 |
whether this makes a difference. Information about malloc is |
|
|
601 |
in the ''INSTALL'' file in the source |
|
|
602 |
distribution. You can find out whether you are using perl's |
|
|
603 |
malloc by typing perl -V:usemymalloc. |
|
|
604 |
|
|
|
605 |
|
|
|
606 |
__Is it unsafe to return a pointer to local |
|
|
607 |
data?__ |
|
|
608 |
|
|
|
609 |
|
|
|
610 |
No, Perl's garbage collection system takes care of |
|
|
611 |
this. |
|
|
612 |
|
|
|
613 |
|
|
|
614 |
sub makeone { |
|
|
615 |
my @a = ( 1 .. 10 ); |
|
|
616 |
return @a; |
|
|
617 |
} |
|
|
618 |
for $i ( 1 .. 10 ) { |
|
|
619 |
push @many, makeone(); |
|
|
620 |
} |
|
|
621 |
print $many[[4][[5], |
|
|
622 |
print |
|
|
623 |
|
|
|
624 |
|
|
|
625 |
__How can I free an array or hash so my program |
|
|
626 |
shrinks?__ |
|
|
627 |
|
|
|
628 |
|
|
|
629 |
You can't. On most operating systems, memory allocated to a |
|
|
630 |
program can never be returned to the system. That's why |
|
|
631 |
long-running programs sometimes re-exec themselves. Some |
|
|
632 |
operating systems (notably, FreeBSD and Linux) allegedly |
|
|
633 |
reclaim large chunks of memory that is no longer used, but |
|
|
634 |
it doesn't appear to happen with Perl (yet). The Mac appears |
|
|
635 |
to be the only platform that will reliably (albeit, slowly) |
|
|
636 |
return memory to the OS . |
|
|
637 |
|
|
|
638 |
|
|
|
639 |
We've had reports that on Linux (Redhat 5.1) on Intel, |
|
|
640 |
undef $scalar will return memory to the system, |
|
|
641 |
while on Solaris 2.6 it won't. In general, try it yourself |
|
|
642 |
and see. |
|
|
643 |
|
|
|
644 |
|
|
|
645 |
However, judicious use of ''my()'' on your variables will |
|
|
646 |
help make sure that they go out of scope so that Perl can |
|
|
647 |
free up that space for use in other parts of your program. A |
|
|
648 |
global variable, of course, never goes out of scope, so you |
|
|
649 |
can't get its space automatically reclaimed, although |
|
|
650 |
''undef()''ing and/or ''delete()''ing it will achieve |
|
|
651 |
the same effect. In general, memory allocation and |
|
|
652 |
de-allocation isn't something you can or should be worrying |
|
|
653 |
about much in Perl, but even this capability (preallocation |
|
|
654 |
of data types) is in the works. |
|
|
655 |
|
|
|
656 |
|
|
|
657 |
__How can I make my CGI script more |
|
|
658 |
efficient?__ |
|
|
659 |
|
|
|
660 |
|
|
|
661 |
Beyond the normal measures described to make general Perl |
|
|
662 |
programs faster or smaller, a CGI program has |
|
|
663 |
additional issues. It may be run several times per second. |
|
|
664 |
Given that each time it runs it will need to be re-compiled |
|
|
665 |
and will often allocate a megabyte or more of system memory, |
|
|
666 |
this can be a killer. Compiling into C __isn't going to |
|
|
667 |
help you__ because the process start-up overhead is where |
|
|
668 |
the bottleneck is. |
|
|
669 |
|
|
|
670 |
|
|
|
671 |
There are two popular ways to avoid this overhead. One |
|
|
672 |
solution involves running the Apache HTTP |
|
|
673 |
server (available from http://www.apache.org/) with either |
|
|
674 |
of the mod_perl or mod_fastcgi plugin modules. |
|
|
675 |
|
|
|
676 |
|
|
|
677 |
With mod_perl and the Apache::Registry module (distributed |
|
|
678 |
with mod_perl), httpd will run with an embedded Perl |
|
|
679 |
interpreter which pre-compiles your script and then executes |
|
|
680 |
it within the same address space without forking. The Apache |
|
|
681 |
extension also gives Perl access to the internal server |
|
|
682 |
API , so modules written in Perl can do just |
|
|
683 |
about anything a module written in C can. For more on |
|
|
684 |
mod_perl, see http://perl.apache.org/ |
|
|
685 |
|
|
|
686 |
|
|
|
687 |
With the FCGI module (from |
|
|
688 |
CPAN ) and the mod_fastcgi module (available |
|
|
689 |
from http://www.fastcgi.com/) each of your Perl programs |
|
|
690 |
becomes a permanent CGI daemon |
|
|
691 |
process. |
|
|
692 |
|
|
|
693 |
|
|
|
694 |
Both of these solutions can have far-reaching effects on |
|
|
695 |
your system and on the way you write your CGI |
|
|
696 |
programs, so investigate them with care. |
|
|
697 |
|
|
|
698 |
|
|
|
699 |
See |
|
|
700 |
http://www.perl.com/CPAN/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/ |
|
|
701 |
. |
|
|
702 |
|
|
|
703 |
|
|
|
704 |
A non-free, commercial product, ``The Velocity Engine for |
|
|
705 |
Perl'', (http://www.binevolve.com/ or |
|
|
706 |
http://www.binevolve.com/velocigen/ ) might also be worth |
|
|
707 |
looking at. It will allow you to increase the performance of |
|
|
708 |
your Perl programs, running programs up to 25 times faster |
|
|
709 |
than normal CGI Perl when running in |
|
|
710 |
persistent Perl mode or 4 to 5 times faster without any |
|
|
711 |
modification to your existing CGI programs. |
|
|
712 |
Fully functional evaluation copies are available from the |
|
|
713 |
web site. |
|
|
714 |
|
|
|
715 |
|
|
|
716 |
__How can I hide the source for my Perl |
|
|
717 |
program?__ |
|
|
718 |
|
|
|
719 |
|
|
|
720 |
Delete it. :-) Seriously, there are a number of (mostly |
|
|
721 |
unsatisfactory) solutions with varying levels of |
|
|
722 |
``security''. |
|
|
723 |
|
|
|
724 |
|
|
|
725 |
First of all, however, you ''can't'' take away read |
|
|
726 |
permission, because the source code has to be readable in |
|
|
727 |
order to be compiled and interpreted. (That doesn't mean |
|
|
728 |
that a CGI script's source is readable by |
|
|
729 |
people on the web, though--only by people with access to the |
|
|
730 |
filesystem.) So you have to leave the permissions at the |
|
|
731 |
socially friendly 0755 level. |
|
|
732 |
|
|
|
733 |
|
|
|
734 |
Some people regard this as a security problem. If your |
|
|
735 |
program does insecure things and relies on people not |
|
|
736 |
knowing how to exploit those insecurities, it is not secure. |
|
|
737 |
It is often possible for someone to determine the insecure |
|
|
738 |
things and exploit them without viewing the source. Security |
|
|
739 |
through obscurity, the name for hiding your bugs instead of |
|
|
740 |
fixing them, is little security indeed. |
|
|
741 |
|
|
|
742 |
|
|
|
743 |
You can try using encryption via source filters (Filter::* |
|
|
744 |
from CPAN ), but any decent programmer will |
|
|
745 |
be able to decrypt it. You can try using the byte code |
|
|
746 |
compiler and interpreter described below, but the curious |
|
|
747 |
might still be able to de-compile it. You can try using the |
|
|
748 |
native-code compiler described below, but crackers might be |
|
|
749 |
able to disassemble it. These pose varying degrees of |
|
|
750 |
difficulty to people wanting to get at your code, but none |
|
|
751 |
can definitively conceal it (true of every language, not |
|
|
752 |
just Perl). |
|
|
753 |
|
|
|
754 |
|
|
|
755 |
If you're concerned about people profiting from your code, |
|
|
756 |
then the bottom line is that nothing but a restrictive |
|
|
757 |
license will give you legal security. License your software |
|
|
758 |
and pepper it with threatening statements like ``This is |
|
|
759 |
unpublished proprietary software of XYZ Corp. |
|
|
760 |
Your access to it does not give you permission to use it |
|
|
761 |
blah blah blah.'' We are not lawyers, of course, so you |
|
|
762 |
should see a lawyer if you want to be sure your license's |
|
|
763 |
wording will stand up in court. |
|
|
764 |
|
|
|
765 |
|
|
|
766 |
__How can I compile my Perl program into byte code or |
|
|
767 |
C?__ |
|
|
768 |
|
|
|
769 |
|
|
|
770 |
Malcolm Beattie has written a multifunction backend |
|
|
771 |
compiler, available from CPAN , that can do |
|
|
772 |
both these things. It is included in the perl5.005 release, |
|
|
773 |
but is still considered experimental. This means it's fun to |
|
|
774 |
play with if you're a programmer but not really for people |
|
|
775 |
looking for turn-key solutions. |
|
|
776 |
|
|
|
777 |
|
|
|
778 |
Merely compiling into C does not in and of itself guarantee |
|
|
779 |
that your code will run very much faster. That's because |
|
|
780 |
except for lucky cases where a lot of native type |
|
|
781 |
inferencing is possible, the normal Perl run-time system is |
|
|
782 |
still present and so your program will take just as long to |
|
|
783 |
run and be just as big. Most programs save little more than |
|
|
784 |
compilation time, leaving execution no more than 10-30% |
|
|
785 |
faster. A few rare programs actually benefit significantly |
|
|
786 |
(even running several times faster), but this takes some |
|
|
787 |
tweaking of your code. |
|
|
788 |
|
|
|
789 |
|
|
|
790 |
You'll probably be astonished to learn that the current |
|
|
791 |
version of the compiler generates a compiled form of your |
|
|
792 |
script whose executable is just as big as the original perl |
|
|
793 |
executable, and then some. That's because as currently |
|
|
794 |
written, all programs are prepared for a full ''eval()'' |
|
|
795 |
statement. You can tremendously reduce this cost by building |
|
|
796 |
a shared ''libperl.so'' library and linking against that. |
|
|
797 |
See the ''INSTALL'' podfile in the Perl |
|
|
798 |
source distribution for details. If you link your main perl |
|
|
799 |
binary with this, it will make it minuscule. For example, on |
|
|
800 |
one author's system, ''/usr/bin/perl'' is only 11k in |
|
|
801 |
size! |
|
|
802 |
|
|
|
803 |
|
|
|
804 |
In general, the compiler will do nothing to make a Perl |
|
|
805 |
program smaller, faster, more portable, or more secure. In |
|
|
806 |
fact, it can make your situation worse. The executable will |
|
|
807 |
be bigger, your VM system may take longer to |
|
|
808 |
load the whole thing, the binary is fragile and hard to fix, |
|
|
809 |
and compilation never stopped software piracy in the form of |
|
|
810 |
crackers, viruses, or bootleggers. The real advantage of the |
|
|
811 |
compiler is merely packaging, and once you see the size of |
|
|
812 |
what it makes (well, unless you use a shared |
|
|
813 |
''libperl.so''), you'll probably want a complete Perl |
|
|
814 |
install anyway. |
|
|
815 |
|
|
|
816 |
|
|
|
817 |
__How can I compile Perl into Java?__ |
|
|
818 |
|
|
|
819 |
|
|
|
820 |
You can also integrate Java and Perl with the Perl Resource |
|
|
821 |
Kit from O'Reilly and Associates. See |
|
|
822 |
http://www.oreilly.com/catalog/prkunix/ . |
|
|
823 |
|
|
|
824 |
|
|
|
825 |
Perl 5.6 comes with Java Perl Lingo, or JPL . |
|
|
826 |
JPL , still in development, allows Perl code |
|
|
827 |
to be called from Java. See jpl/README in the Perl source |
|
|
828 |
tree. |
|
|
829 |
|
|
|
830 |
|
|
|
831 |
__How can I get__ #!perl __to work on [[ |
|
|
832 |
MS-DOS ,NT,...]?__ |
|
|
833 |
|
|
|
834 |
|
|
|
835 |
For OS/2 just use |
|
|
836 |
|
|
|
837 |
|
|
|
838 |
extproc perl -S -your_switches |
|
|
839 |
as the first line in *.cmd file (-S due to a bug in cmd.exe's `extproc' handling). For DOS one should first invent a corresponding batch file and codify it in ALTERNATIVE_SHEBANG (see the ''INSTALL'' file in the source distribution for more information). |
|
|
840 |
|
|
|
841 |
|
|
|
842 |
The Win95/NT installation, when using the !ActiveState port |
|
|
843 |
of Perl, will modify the Registry to associate the |
|
|
844 |
.pl extension with the perl interpreter. If you |
|
|
845 |
install another port, perhaps even building your own |
|
|
846 |
Win95/NT Perl from the standard sources by using a Windows |
|
|
847 |
port of gcc (e.g., with cygwin or mingw32), then you'll have |
|
|
848 |
to modify the Registry yourself. In addition to associating |
|
|
849 |
.pl with the interpreter, NT people |
|
|
850 |
can use: SET PATHEXT=%PATHEXT%;.PL to let them run |
|
|
851 |
the program install-linux.pl merely by typing |
|
|
852 |
install-linux. |
|
|
853 |
|
|
|
854 |
|
|
|
855 |
Macintosh Perl programs will have the appropriate Creator |
|
|
856 |
and Type, so that double-clicking them will invoke the Perl |
|
|
857 |
application. |
|
|
858 |
|
|
|
859 |
|
|
|
860 |
''IMPORTANT !'': Whatever you do, |
|
|
861 |
PLEASE don't get frustrated, and just throw |
|
|
862 |
the perl interpreter into your cgi-bin directory, in order |
|
|
863 |
to get your programs working for a web server. This is an |
|
|
864 |
EXTREMELY big security risk. Take the time to |
|
|
865 |
figure out how to do it correctly. |
|
|
866 |
|
|
|
867 |
|
|
|
868 |
__Can I write useful Perl programs on the command |
|
|
869 |
line?__ |
|
|
870 |
|
|
|
871 |
|
|
|
872 |
Yes. Read perlrun for more information. Some examples |
|
|
873 |
follow. (These assume standard Unix shell quoting |
|
|
874 |
rules.) |
|
|
875 |
|
|
|
876 |
|
|
|
877 |
# sum first and last fields |
|
|
878 |
perl -lane 'print $F[[0] + $F[[-1]' * |
|
|
879 |
# identify text files |
|
|
880 |
perl -le 'for(@ARGV) {print if -f |
|
|
881 |
# remove (most) comments from C program |
|
|
882 |
perl -0777 -pe 's{/*.*?*/}{}gs' foo.c |
|
|
883 |
# make file a month younger than today, defeating reaper daemons |
|
|
884 |
perl -e '$X=24*60*60; utime(time(),time() + 30 * $X,@ARGV)' * |
|
|
885 |
# find first unused uid |
|
|
886 |
perl -le '$i++ while getpwuid($i); print $i' |
|
|
887 |
# display reasonable manpath |
|
|
888 |
echo $PATH perl -nl -072 -e ' |
|
|
889 |
s![[^/+]*$!man! |
|
|
890 |
OK , the last one was actually an Obfuscated Perl Contest entry. :-) |
|
|
891 |
|
|
|
892 |
|
|
|
893 |
__Why don't Perl one-liners work on my DOS/Mac/VMS |
|
|
894 |
system?__ |
|
|
895 |
|
|
|
896 |
|
|
|
897 |
The problem is usually that the command interpreters on |
|
|
898 |
those systems have rather different ideas about quoting than |
|
|
899 |
the Unix shells under which the one-liners were created. On |
|
|
900 |
some systems, you may have to change single-quotes to double |
|
|
901 |
ones, which you must ''NOT'' do on Unix or |
|
|
902 |
Plan9 systems. You might also have to change a single % to a |
|
|
903 |
%%. |
|
|
904 |
|
|
|
905 |
|
|
|
906 |
For example: |
|
|
907 |
|
|
|
908 |
|
|
|
909 |
# Unix |
|
|
910 |
perl -e 'print |
|
|
911 |
# DOS, etc. |
|
|
912 |
perl -e |
|
|
913 |
# Mac |
|
|
914 |
print |
|
|
915 |
# VMS |
|
|
916 |
perl -e |
|
|
917 |
The problem is that none of these examples are reliable: they depend on the command interpreter. Under Unix, the first two often work. Under DOS , it's entirely possible that neither works. If 4DOS was the command shell, you'd probably have better luck like this: |
|
|
918 |
|
|
|
919 |
|
|
|
920 |
perl -e |
|
|
921 |
Under the Mac, it depends which environment you are using. The !MacPerl shell, or MPW , is much like Unix shells in its support for several quoting variants, except that it makes free use of the Mac's non-ASCII characters as control characters. |
|
|
922 |
|
|
|
923 |
|
|
|
924 |
Using ''qq()'', q(), and ''qx()'', instead of ``double |
|
|
925 |
quotes'', 'single quotes', and `backticks`, may make |
|
|
926 |
one-liners easier to write. |
|
|
927 |
|
|
|
928 |
|
|
|
929 |
There is no general solution to all of this. It is a mess, |
|
|
930 |
pure and simple. Sucks to be away from Unix, huh? |
|
|
931 |
:-) |
|
|
932 |
|
|
|
933 |
|
|
|
934 |
[[Some of this answer was contributed by Kenneth |
|
|
935 |
Albanowski.] |
|
|
936 |
|
|
|
937 |
|
|
|
938 |
__Where can I learn about CGI or Web |
|
|
939 |
programming in Perl?__ |
|
|
940 |
|
|
|
941 |
|
|
|
942 |
For modules, get the CGI or |
|
|
943 |
LWP modules from CPAN . For |
|
|
944 |
textbooks, see the two especially dedicated to web stuff in |
|
|
945 |
the question on books. For problems and questions related to |
|
|
946 |
the web, like ``Why do I get 500 Errors'' or ``Why doesn't |
|
|
947 |
it run from the browser right when it runs fine on the |
|
|
948 |
command line'', see these sources: |
|
|
949 |
|
|
|
950 |
|
|
|
951 |
WWW Security FAQ |
|
|
952 |
http://www.w3.org/Security/Faq/ |
|
|
953 |
Web FAQ |
|
|
954 |
http://www.boutell.com/faq/ |
|
|
955 |
CGI FAQ |
|
|
956 |
http://www.webthing.com/tutorials/cgifaq.html |
|
|
957 |
HTTP Spec |
|
|
958 |
http://www.w3.org/pub/WWW/Protocols/HTTP/ |
|
|
959 |
HTML Spec |
|
|
960 |
http://www.w3.org/TR/REC-html40/ |
|
|
961 |
http://www.w3.org/pub/WWW/!MarkUp/ |
|
|
962 |
CGI Spec |
|
|
963 |
http://www.w3.org/CGI/ |
|
|
964 |
CGI Security FAQ |
|
|
965 |
http://www.go2net.com/people/paulp/cgi-security/safe-cgi.txt |
|
|
966 |
|
|
|
967 |
|
|
|
968 |
__Where can I learn about object-oriented Perl |
|
|
969 |
programming?__ |
|
|
970 |
|
|
|
971 |
|
|
|
972 |
A good place to start is perltoot, and you can use perlobj, |
|
|
973 |
perlboot, and perlbot for reference. Perltoot didn't come |
|
|
974 |
out until the 5.004 release; you can get a copy (in pod, |
|
|
975 |
html, or postscript) from |
|
|
976 |
http://www.perl.com/CPAN/doc/FMTEYEWTK/ . |
|
|
977 |
|
|
|
978 |
|
|
|
979 |
__Where can I learn about linking C with Perl? [[h2xs, |
|
|
980 |
xsubpp]__ |
|
|
981 |
|
|
|
982 |
|
|
|
983 |
If you want to call C from Perl, start with perlxstut, |
|
|
984 |
moving on to perlxs, xsubpp, and perlguts. If you want to |
|
|
985 |
call Perl from C, then read perlembed, perlcall, and |
|
|
986 |
perlguts. Don't forget that you can learn a lot from looking |
|
|
987 |
at how the authors of existing extension modules wrote their |
|
|
988 |
code and solved their problems. |
|
|
989 |
|
|
|
990 |
|
|
|
991 |
__I've read perlembed, perlguts, etc., but I can't embed |
|
|
992 |
perl in my C program; what am I doing |
|
|
993 |
wrong?__ |
|
|
994 |
|
|
|
995 |
|
|
|
996 |
Download the !ExtUtils::Embed kit from CPAN |
|
|
997 |
and run `make test'. If the tests pass, read the pods again |
|
|
998 |
and again and again. If they fail, see perlbug and send a |
|
|
999 |
bug report with the output of make test |
|
|
1000 |
TEST_VERBOSE=1 along with perl |
|
|
1001 |
-V. |
|
|
1002 |
|
|
|
1003 |
|
|
|
1004 |
__When I tried to run my script, I got this message. What |
|
|
1005 |
does it mean?__ |
|
|
1006 |
|
|
|
1007 |
|
|
|
1008 |
A complete list of Perl's error messages and warnings with |
|
|
1009 |
explanatory text can be found in perldiag. You can also use |
|
|
1010 |
the splain program (distributed with Perl) to explain the |
|
|
1011 |
error messages: |
|
|
1012 |
|
|
|
1013 |
|
|
|
1014 |
perl program 2 |
|
|
1015 |
or change your program to explain the messages for you: |
|
|
1016 |
|
|
|
1017 |
|
|
|
1018 |
use diagnostics; |
|
|
1019 |
or |
|
|
1020 |
|
|
|
1021 |
|
|
|
1022 |
use diagnostics -verbose; |
|
|
1023 |
|
|
|
1024 |
|
|
|
1025 |
__What's !MakeMaker?__ |
|
|
1026 |
|
|
|
1027 |
|
|
|
1028 |
This module (part of the standard Perl distribution) is |
|
|
1029 |
designed to write a Makefile for an extension module from a |
|
|
1030 |
Makefile.PL. For more information, see |
|
|
1031 |
!ExtUtils::!MakeMaker. |
|
|
1032 |
!!AUTHOR AND COPYRIGHT |
|
|
1033 |
|
|
|
1034 |
|
|
|
1035 |
Copyright (c) 1997-1999 Tom Christiansen and Nathan |
|
|
1036 |
Torkington. All rights reserved. |
|
|
1037 |
|
|
|
1038 |
|
|
|
1039 |
When included as an integrated part of the Standard |
|
|
1040 |
Distribution of Perl or of its documentation (printed or |
|
|
1041 |
otherwise), this works is covered under Perl's Artistic |
|
|
1042 |
License. For separate distributions of all or part of this |
|
|
1043 |
FAQ outside of that, see |
|
|
1044 |
perlfaq. |
|
|
1045 |
|
|
|
1046 |
|
|
|
1047 |
Irrespective of its distribution, all code examples here are |
|
|
1048 |
in the public domain. You are permitted and encouraged to |
|
|
1049 |
use this code and any derivatives thereof in your own |
|
|
1050 |
programs for fun or for profit as you see fit. A simple |
|
|
1051 |
comment in the code giving credit to the FAQ |
|
|
1052 |
would be courteous but is not required. |
|
|
1053 |
---- |