Re: [PATCH pod/[bt]ootc?.pod] Adding mention of useful CPAN modules
[p5sagit/p5-mst-13.2.git] / pod / perlmodlib.PL
CommitLineData
2e1d04bc 1#!../miniperl
2
3open (OUT, ">perlmodlib.tmp") or die $!;
4my (@pragma, @mod);
5open (MANIFEST, "../MANIFEST") or die $!;
6
7while (<MANIFEST>) {
8 my $filename;
9 next unless s|^lib/|| or m|^ext/|;
10 ($filename) = /(\S+)/;
11 $filename =~ s|^[^/]+/|| if $filename =~ s|^ext/||;
12 next unless $filename =~ /\.pm$/;
13 next unless open (MOD, "../lib/$filename");
14 my ($name, $thing);
15 my $foundit=0;
16 {local $/="";
17 while (<MOD>) {
18 next unless /^=head1 NAME/;
19 $foundit++;
20 last;
21 }
22 }
23 next unless $foundit;
24 my $title = <MOD>;
25 chomp($title);
26 close MOD;
27
28 my $perlname = $filename;
29 $perlname =~ s|\.pm$||;
30 $perlname =~ s|/|::|g;
31
32 ($name, $thing) = split / - /, $title,2;
33 next unless $name and $thing;
34 $thing=~s/^perl pragma to //i;
35 $thing=ucfirst($thing);
36 $title = "=item $perlname\n\n$thing\n\n";
37
38 if ($filename=~/[A-Z]/) {
39 push @mod, $title;
40 } else {
41 push @pragma, $title;
42 }
43}
44
45print OUT <<'EOF';
46=head1 NAME
47
48perlmodlib - constructing new Perl modules and finding existing ones
49
50=head1 DESCRIPTION
51
52=head1 THE PERL MODULE LIBRARY
53
54Many modules are included the Perl distribution. These are described
55below, and all end in F<.pm>. You may discover compiled library
56file (usually ending in F<.so>) or small pieces of modules to be
57autoloaded (ending in F<.al>); these were automatically generated
58by the installation process. You may also discover files in the
59library directory that end in either F<.pl> or F<.ph>. These are
60old libraries supplied so that old programs that use them still
61run. The F<.pl> files will all eventually be converted into standard
62modules, and the F<.ph> files made by B<h2ph> will probably end up
63as extension modules made by B<h2xs>. (Some F<.ph> values may
64already be available through the POSIX, Errno, or Fcntl modules.)
65The B<pl2pm> file in the distribution may help in your conversion,
66but it's just a mechanical process and therefore far from bulletproof.
67
68=head2 Pragmatic Modules
69
70They work somewhat like compiler directives (pragmata) in that they
71tend to affect the compilation of your program, and thus will usually
72work well only when used within a C<use>, or C<no>. Most of these
73are lexically scoped, so an inner BLOCK may countermand them
74by saying:
75
76 no integer;
77 no strict 'refs';
78 no warnings;
79
80which lasts until the end of that BLOCK.
81
82Some pragmas are lexically scoped--typically those that affect the
83C<$^H> hints variable. Others affect the current package instead,
84like C<use vars> and C<use subs>, which allow you to predeclare a
85variables or subroutines within a particular I<file> rather than
86just a block. Such declarations are effective for the entire file
87for which they were declared. You cannot rescind them with C<no
88vars> or C<no subs>.
89
90The following pragmas are defined (and have their own documentation).
91
92=over 12
93
94EOF
95
96print OUT $_ for (sort @pragma);
97
98print OUT <<EOF;
99=back
100
101=head2 Standard Modules
102
103Standard, bundled modules are all expected to behave in a well-defined
104manner with respect to namespace pollution because they use the
105Exporter module. See their own documentation for details.
106
107=over 12
108
109EOF
110
111print OUT $_ for (sort @mod);
112
113print OUT <<'EOF';
114=back
115
116To find out I<all> modules installed on your system, including
117those without documentation or outside the standard release,
309a139e 118just do this:
2e1d04bc 119
120 % find `perl -e 'print "@INC"'` -name '*.pm' -print
121
122They should all have their own documentation installed and accessible
123via your system man(1) command. If you do not have a B<find>
124program, you can use the Perl B<find2perl> program instead, which
125generates Perl code as output you can run through perl. If you
126have a B<man> program but it doesn't find your modules, you'll have
127to fix your manpath. See L<perl> for details. If you have no
128system B<man> command, you might try the B<perldoc> program.
129
130=head2 Extension Modules
131
132Extension modules are written in C (or a mix of Perl and C). They
133are usually dynamically loaded into Perl if and when you need them,
134but may also be be linked in statically. Supported extension modules
135include Socket, Fcntl, and POSIX.
136
137Many popular C extension modules do not come bundled (at least, not
138completely) due to their sizes, volatility, or simply lack of time
139for adequate testing and configuration across the multitude of
140platforms on which Perl was beta-tested. You are encouraged to
141look for them on CPAN (described below), or using web search engines
142like Alta Vista or Deja News.
143
144=head1 CPAN
145
146CPAN stands for Comprehensive Perl Archive Network; it's a globally
147replicated trove of Perl materials, including documentation, style
148guides, tricks and traps, alternate ports to non-Unix systems and
149occasional binary distributions for these. Search engines for
150CPAN can be found at http://cpan.perl.com/ and at
151http://theory.uwinnipeg.ca/mod_perl/cpan-search.pl .
152
153Most importantly, CPAN includes around a thousand unbundled modules,
154some of which require a C compiler to build. Major categories of
155modules are:
156
157=over
158
159=item *
ac634a9a 160
2e1d04bc 161Language Extensions and Documentation Tools
162
163=item *
ac634a9a 164
2e1d04bc 165Development Support
166
167=item *
ac634a9a 168
2e1d04bc 169Operating System Interfaces
170
171=item *
ac634a9a 172
2e1d04bc 173Networking, Device Control (modems) and InterProcess Communication
174
175=item *
ac634a9a 176
2e1d04bc 177Data Types and Data Type Utilities
178
179=item *
ac634a9a 180
2e1d04bc 181Database Interfaces
182
183=item *
ac634a9a 184
2e1d04bc 185User Interfaces
186
187=item *
ac634a9a 188
2e1d04bc 189Interfaces to / Emulations of Other Programming Languages
190
191=item *
ac634a9a 192
2e1d04bc 193File Names, File Systems and File Locking (see also File Handles)
194
195=item *
ac634a9a 196
2e1d04bc 197String Processing, Language Text Processing, Parsing, and Searching
198
199=item *
ac634a9a 200
2e1d04bc 201Option, Argument, Parameter, and Configuration File Processing
202
203=item *
ac634a9a 204
2e1d04bc 205Internationalization and Locale
206
207=item *
ac634a9a 208
2e1d04bc 209Authentication, Security, and Encryption
210
211=item *
ac634a9a 212
2e1d04bc 213World Wide Web, HTML, HTTP, CGI, MIME
214
215=item *
ac634a9a 216
2e1d04bc 217Server and Daemon Utilities
218
219=item *
ac634a9a 220
2e1d04bc 221Archiving and Compression
222
223=item *
ac634a9a 224
2e1d04bc 225Images, Pixmap and Bitmap Manipulation, Drawing, and Graphing
226
227=item *
ac634a9a 228
2e1d04bc 229Mail and Usenet News
230
231=item *
ac634a9a 232
2e1d04bc 233Control Flow Utilities (callbacks and exceptions etc)
234
235=item *
ac634a9a 236
2e1d04bc 237File Handle and Input/Output Stream Utilities
238
239=item *
ac634a9a 240
2e1d04bc 241Miscellaneous Modules
242
243=back
244
245Registered CPAN sites as of this writing include the following.
246You should try to choose one close to you:
247
248=over
249
250=item Africa
251
252 South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
253 ftp://ftp.saix.net/pub/CPAN/
254 ftp://ftp.sun.ac.za/CPAN/
255 ftp://ftpza.co.za/pub/mirrors/cpan/
256
257
258=item Asia
259
260 China ftp://freesoft.cei.gov.cn/pub/languages/perl/CPAN/
261 Hong Kong ftp://ftp.pacific.net.hk/pub/mirror/CPAN/
262 Indonesia ftp://malone.piksi.itb.ac.id/pub/CPAN/
263 Israel ftp://bioinfo.weizmann.ac.il/pub/software/perl/CPAN/
264 Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
265 ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/
266 ftp://ftp.lab.kdd.co.jp/lang/perl/CPAN/
267 ftp://ftp.meisei-u.ac.jp/pub/CPAN/
268 ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/
269 ftp://mirror.nucba.ac.jp/mirror/Perl/
270 Saudi-Arabia ftp://ftp.isu.net.sa/pub/CPAN/
271 Singapore ftp://ftp.nus.edu.sg/pub/unix/perl/CPAN/
272 South Korea ftp://ftp.bora.net/pub/CPAN/
273 ftp://ftp.kornet.net/pub/CPAN/
274 ftp://ftp.nuri.net/pub/CPAN/
275 Taiwan ftp://coda.nctu.edu.tw/computer-languages/perl/CPAN/
276 ftp://ftp.ee.ncku.edu.tw/pub3/perl/CPAN/
277 ftp://ftp1.sinica.edu.tw/pub1/perl/CPAN/
278 Thailand ftp://ftp.nectec.or.th/pub/mirrors/CPAN/
279
280
281=item Australasia
282
283 Australia ftp://cpan.topend.com.au/pub/CPAN/
284 ftp://ftp.labyrinth.net.au/pub/perl-CPAN/
285 ftp://ftp.sage-au.org.au/pub/compilers/perl/CPAN/
286 ftp://mirror.aarnet.edu.au/pub/perl/CPAN/
287 New Zealand ftp://ftp.auckland.ac.nz/pub/perl/CPAN/
288 ftp://sunsite.net.nz/pub/languages/perl/CPAN/
289
290
291=item Central America
292
293 Costa Rica ftp://ftp.ucr.ac.cr/pub/Unix/CPAN/
294
295
296=item Europe
297
298 Austria ftp://ftp.tuwien.ac.at/pub/languages/perl/CPAN/
299 Belgium ftp://ftp.kulnet.kuleuven.ac.be/pub/mirror/CPAN/
300 Bulgaria ftp://ftp.ntrl.net/pub/mirrors/CPAN/
301 Croatia ftp://ftp.linux.hr/pub/CPAN/
302 Czech Republic ftp://ftp.fi.muni.cz/pub/perl/
303 ftp://sunsite.mff.cuni.cz/Languages/Perl/CPAN/
304 Denmark ftp://sunsite.auc.dk/pub/languages/perl/CPAN/
305 Estonia ftp://ftp.ut.ee/pub/languages/perl/CPAN/
306 Finland ftp://ftp.funet.fi/pub/languages/perl/CPAN/
307 France ftp://ftp.grolier.fr/pub/perl/CPAN/
308 ftp://ftp.lip6.fr/pub/perl/CPAN/
309 ftp://ftp.oleane.net/pub/mirrors/CPAN/
310 ftp://ftp.pasteur.fr/pub/computing/CPAN/
311 ftp://ftp.uvsq.fr/pub/perl/CPAN/
312 German ftp://ftp.gigabell.net/pub/CPAN/
313 Germany ftp://ftp.archive.de.uu.net/pub/CPAN/
314 ftp://ftp.freenet.de/pub/ftp.cpan.org/pub/
315 ftp://ftp.gmd.de/packages/CPAN/
316 ftp://ftp.gwdg.de/pub/languages/perl/CPAN/
317
318ftp://ftp.leo.org/pub/comp/general/programming/languages/script/perl/CPAN/
319 ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/
320 ftp://ftp.rz.ruhr-uni-bochum.de/pub/CPAN/
321 ftp://ftp.uni-erlangen.de/pub/source/CPAN/
322 ftp://ftp.uni-hamburg.de/pub/soft/lang/perl/CPAN/
323 Germany ftp://ftp.archive.de.uu.net/pub/CPAN/
324 ftp://ftp.freenet.de/pub/ftp.cpan.org/pub/
325 ftp://ftp.gmd.de/packages/CPAN/
326 ftp://ftp.gwdg.de/pub/languages/perl/CPAN/
327
328ftp://ftp.leo.org/pub/comp/general/programming/languages/script/perl/CPAN/
329 ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/
330 ftp://ftp.rz.ruhr-uni-bochum.de/pub/CPAN/
331 ftp://ftp.uni-erlangen.de/pub/source/CPAN/
332 ftp://ftp.uni-hamburg.de/pub/soft/lang/perl/CPAN/
333 Greece ftp://ftp.ntua.gr/pub/lang/perl/
334 Hungary ftp://ftp.kfki.hu/pub/packages/perl/CPAN/
335 Iceland ftp://ftp.gm.is/pub/CPAN/
336 Ireland ftp://cpan.indigo.ie/pub/CPAN/
337 ftp://sunsite.compapp.dcu.ie/pub/perl/
338 Italy ftp://cis.uniRoma2.it/CPAN/
339 ftp://ftp.flashnet.it/pub/CPAN/
340 ftp://ftp.unina.it/pub/Other/CPAN/
341 ftp://ftp.unipi.it/pub/mirror/perl/CPAN/
342 Netherlands ftp://ftp.cs.uu.nl/mirror/CPAN/
343 ftp://ftp.nluug.nl/pub/languages/perl/CPAN/
344 Norway ftp://ftp.uit.no/pub/languages/perl/cpan/
345 ftp://sunsite.uio.no/pub/languages/perl/CPAN/
346 Poland ftp://ftp.man.torun.pl/pub/CPAN/
347 ftp://ftp.pk.edu.pl/pub/lang/perl/CPAN/
348 ftp://sunsite.icm.edu.pl/pub/CPAN/
349 Portugal ftp://ftp.ci.uminho.pt/pub/mirrors/cpan/
350 ftp://ftp.ist.utl.pt/pub/CPAN/
351 ftp://ftp.ua.pt/pub/CPAN/
352 Romania ftp://ftp.dnttm.ro/pub/CPAN/
353 Russia ftp://ftp.chg.ru/pub/lang/perl/CPAN/
354 ftp://ftp.sai.msu.su/pub/lang/perl/CPAN/
355 Slovakia ftp://ftp.entry.sk/pub/languages/perl/CPAN/
356 Slovenia ftp://ftp.arnes.si/software/perl/CPAN/
357 Spain ftp://ftp.etse.urv.es/pub/perl/
358 ftp://ftp.rediris.es/mirror/CPAN/
359 Sweden ftp://ftp.sunet.se/pub/lang/perl/CPAN/
360 Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
361 Turkey ftp://sunsite.bilkent.edu.tr/pub/languages/CPAN/
362 United Kingdom ftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/
363 ftp://ftp.flirble.org/pub/languages/perl/CPAN/
364
365ftp://ftp.mirror.ac.uk/sites/ftp.funet.fi/pub/languages/perl/CPAN/
366 ftp://ftp.plig.org/pub/CPAN/
367 ftp://sunsite.doc.ic.ac.uk/packages/CPAN/
368
369
370=item North America
371
372 Alberta ftp://sunsite.ualberta.ca/pub/Mirror/CPAN/
373 California ftp://cpan.nas.nasa.gov/pub/perl/CPAN/
374 ftp://cpan.valueclick.com/CPAN/
375 ftp://ftp.cdrom.com/pub/perl/CPAN/
376 http://download.sourceforge.net/mirrors/CPAN/
377 Colorado ftp://ftp.cs.colorado.edu/pub/perl/CPAN/
378 Florida ftp://ftp.cise.ufl.edu/pub/perl/CPAN/
379 Georgia ftp://ftp.twoguys.org/CPAN/
380 Illinois ftp://uiarchive.uiuc.edu/pub/lang/perl/CPAN/
381 Indiana ftp://csociety-ftp.ecn.purdue.edu/pub/CPAN/
382 ftp://ftp.uwsg.indiana.edu/pub/perl/CPAN/
383 Kentucky ftp://ftp.uky.edu/CPAN/
384 Manitoba ftp://theoryx5.uwinnipeg.ca/pub/CPAN/
385 Massachusetts
386ftp://ftp.ccs.neu.edu/net/mirrors/ftp.funet.fi/pub/languages/perl/CPAN/
387 ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN/
388 Mexico ftp://ftp.msg.com.mx/pub/CPAN/
389 New York ftp://ftp.deao.net/pub/CPAN/
390 ftp://ftp.rge.com/pub/languages/perl/
391 North Carolina ftp://ftp.duke.edu/pub/perl/
392 Nova Scotia ftp://cpan.chebucto.ns.ca/pub/CPAN/
393 Oklahoma ftp://ftp.ou.edu/mirrors/CPAN/
394 Ontario ftp://ftp.crc.ca/pub/packages/lang/perl/CPAN/
395 Oregon ftp://ftp.orst.edu/pub/packages/CPAN/
396 Pennsylvania ftp://ftp.epix.net/pub/languages/perl/
397 Tennessee ftp://ftp.sunsite.utk.edu/pub/CPAN/
398 Texas ftp://ftp.sedl.org/pub/mirrors/CPAN/
399 ftp://jhcloos.com/pub/mirror/CPAN/
400 Utah ftp://mirror.xmission.com/CPAN/
401 Virginia ftp://ftp.perl.org/pub/perl/CPAN/
402 ftp://ruff.cs.jmu.edu/pub/CPAN/
403 Washington ftp://ftp-mirror.internap.com/pub/CPAN/
404 ftp://ftp.llarian.net/pub/CPAN/
405 ftp://ftp.spu.edu/pub/CPAN/
406
407
408=item South America
409
410 Brazil ftp://cpan.if.usp.br/pub/mirror/CPAN/
411 ftp://ftp.matrix.com.br/pub/perl/
412 Chile ftp://sunsite.dcc.uchile.cl/pub/Lang/PERL/
413
414=back
415
416For an up-to-date listing of CPAN sites,
417see http://www.perl.com/perl/CPAN/SITES or ftp://www.perl.com/CPAN/SITES .
418
419=head1 Modules: Creation, Use, and Abuse
420
421(The following section is borrowed directly from Tim Bunce's modules
422file, available at your nearest CPAN site.)
423
424Perl implements a class using a package, but the presence of a
425package doesn't imply the presence of a class. A package is just a
426namespace. A class is a package that provides subroutines that can be
427used as methods. A method is just a subroutine that expects, as its
428first argument, either the name of a package (for "static" methods),
429or a reference to something (for "virtual" methods).
430
431A module is a file that (by convention) provides a class of the same
432name (sans the .pm), plus an import method in that class that can be
433called to fetch exported symbols. This module may implement some of
434its methods by loading dynamic C or C++ objects, but that should be
435totally transparent to the user of the module. Likewise, the module
436might set up an AUTOLOAD function to slurp in subroutine definitions on
437demand, but this is also transparent. Only the F<.pm> file is required to
438exist. See L<perlsub>, L<perltoot>, and L<AutoLoader> for details about
439the AUTOLOAD mechanism.
440
441=head2 Guidelines for Module Creation
442
443=over 4
444
ac634a9a 445=item *
446
447Do similar modules already exist in some form?
2e1d04bc 448
449If so, please try to reuse the existing modules either in whole or
450by inheriting useful features into a new class. If this is not
451practical try to get together with the module authors to work on
452extending or enhancing the functionality of the existing modules.
453A perfect example is the plethora of packages in perl4 for dealing
454with command line options.
455
456If you are writing a module to expand an already existing set of
457modules, please coordinate with the author of the package. It
458helps if you follow the same naming scheme and module interaction
459scheme as the original author.
460
ac634a9a 461=item *
462
463Try to design the new module to be easy to extend and reuse.
2e1d04bc 464
465Try to C<use warnings;> (or C<use warnings qw(...);>).
466Remember that you can add C<no warnings qw(...);> to individual blocks
467of code that need less warnings.
468
469Use blessed references. Use the two argument form of bless to bless
470into the class name given as the first parameter of the constructor,
471e.g.,:
472
473 sub new {
474 my $class = shift;
475 return bless {}, $class;
476 }
477
478or even this if you'd like it to be used as either a static
479or a virtual method.
480
481 sub new {
482 my $self = shift;
483 my $class = ref($self) || $self;
484 return bless {}, $class;
485 }
486
487Pass arrays as references so more parameters can be added later
488(it's also faster). Convert functions into methods where
489appropriate. Split large methods into smaller more flexible ones.
490Inherit methods from other modules if appropriate.
491
492Avoid class name tests like: C<die "Invalid" unless ref $ref eq 'FOO'>.
493Generally you can delete the C<eq 'FOO'> part with no harm at all.
494Let the objects look after themselves! Generally, avoid hard-wired
495class names as far as possible.
496
497Avoid C<< $r->Class::func() >> where using C<@ISA=qw(... Class ...)> and
498C<< $r->func() >> would work (see L<perlbot> for more details).
499
500Use autosplit so little used or newly added functions won't be a
501burden to programs that don't use them. Add test functions to
502the module after __END__ either using AutoSplit or by saying:
503
504 eval join('',<main::DATA>) || die $@ unless caller();
505
506Does your module pass the 'empty subclass' test? If you say
507C<@SUBCLASS::ISA = qw(YOURCLASS);> your applications should be able
508to use SUBCLASS in exactly the same way as YOURCLASS. For example,
509does your application still work if you change: C<$obj = new YOURCLASS;>
510into: C<$obj = new SUBCLASS;> ?
511
512Avoid keeping any state information in your packages. It makes it
513difficult for multiple other packages to use yours. Keep state
514information in objects.
515
516Always use B<-w>.
517
518Try to C<use strict;> (or C<use strict qw(...);>).
519Remember that you can add C<no strict qw(...);> to individual blocks
520of code that need less strictness.
521
522Always use B<-w>.
523
524Follow the guidelines in the perlstyle(1) manual.
525
526Always use B<-w>.
527
ac634a9a 528=item *
529
530Some simple style guidelines
2e1d04bc 531
532The perlstyle manual supplied with Perl has many helpful points.
533
534Coding style is a matter of personal taste. Many people evolve their
535style over several years as they learn what helps them write and
536maintain good code. Here's one set of assorted suggestions that
537seem to be widely used by experienced developers:
538
539Use underscores to separate words. It is generally easier to read
540$var_names_like_this than $VarNamesLikeThis, especially for
541non-native speakers of English. It's also a simple rule that works
542consistently with VAR_NAMES_LIKE_THIS.
543
544Package/Module names are an exception to this rule. Perl informally
545reserves lowercase module names for 'pragma' modules like integer
546and strict. Other modules normally begin with a capital letter and
547use mixed case with no underscores (need to be short and portable).
548
549You may find it helpful to use letter case to indicate the scope
550or nature of a variable. For example:
551
552 $ALL_CAPS_HERE constants only (beware clashes with Perl vars)
553 $Some_Caps_Here package-wide global/static
554 $no_caps_here function scope my() or local() variables
555
556Function and method names seem to work best as all lowercase.
557e.g., C<< $obj->as_string() >>.
558
559You can use a leading underscore to indicate that a variable or
560function should not be used outside the package that defined it.
561
ac634a9a 562=item *
563
564Select what to export.
2e1d04bc 565
566Do NOT export method names!
567
568Do NOT export anything else by default without a good reason!
569
570Exports pollute the namespace of the module user. If you must
571export try to use @EXPORT_OK in preference to @EXPORT and avoid
572short or common names to reduce the risk of name clashes.
573
574Generally anything not exported is still accessible from outside the
575module using the ModuleName::item_name (or C<< $blessed_ref->method >>)
576syntax. By convention you can use a leading underscore on names to
577indicate informally that they are 'internal' and not for public use.
578
579(It is actually possible to get private functions by saying:
580C<my $subref = sub { ... }; &$subref;>. But there's no way to call that
581directly as a method, because a method must have a name in the symbol
582table.)
583
584As a general rule, if the module is trying to be object oriented
585then export nothing. If it's just a collection of functions then
586@EXPORT_OK anything but use @EXPORT with caution.
587
ac634a9a 588=item *
589
590Select a name for the module.
2e1d04bc 591
592This name should be as descriptive, accurate, and complete as
593possible. Avoid any risk of ambiguity. Always try to use two or
594more whole words. Generally the name should reflect what is special
595about what the module does rather than how it does it. Please use
596nested module names to group informally or categorize a module.
597There should be a very good reason for a module not to have a nested name.
598Module names should begin with a capital letter.
599
600Having 57 modules all called Sort will not make life easy for anyone
601(though having 23 called Sort::Quick is only marginally better :-).
602Imagine someone trying to install your module alongside many others.
603If in any doubt ask for suggestions in comp.lang.perl.misc.
604
605If you are developing a suite of related modules/classes it's good
606practice to use nested classes with a common prefix as this will
607avoid namespace clashes. For example: Xyz::Control, Xyz::View,
608Xyz::Model etc. Use the modules in this list as a naming guide.
609
610If adding a new module to a set, follow the original author's
611standards for naming modules and the interface to methods in
612those modules.
613
4844a3be 614If developing modules for private internal or project specific use,
615that will never be released to the public, then you should ensure
616that their names will not clash with any future public module. You
617can do this either by using the reserved Local::* category or by
618using a category name that includes an underscore like Foo_Corp::*.
619
2e1d04bc 620To be portable each component of a module name should be limited to
62111 characters. If it might be used on MS-DOS then try to ensure each is
622unique in the first 8 characters. Nested modules make this easier.
623
ac634a9a 624=item *
625
626Have you got it right?
2e1d04bc 627
628How do you know that you've made the right decisions? Have you
629picked an interface design that will cause problems later? Have
630you picked the most appropriate name? Do you have any questions?
631
632The best way to know for sure, and pick up many helpful suggestions,
633is to ask someone who knows. Comp.lang.perl.misc is read by just about
634all the people who develop modules and it's the best place to ask.
635
636All you need to do is post a short summary of the module, its
637purpose and interfaces. A few lines on each of the main methods is
638probably enough. (If you post the whole module it might be ignored
639by busy people - generally the very people you want to read it!)
640
641Don't worry about posting if you can't say when the module will be
642ready - just say so in the message. It might be worth inviting
643others to help you, they may be able to complete it for you!
644
ac634a9a 645=item *
646
647README and other Additional Files.
2e1d04bc 648
649It's well known that software developers usually fully document the
650software they write. If, however, the world is in urgent need of
651your software and there is not enough time to write the full
652documentation please at least provide a README file containing:
653
654=over 10
655
656=item *
ac634a9a 657
2e1d04bc 658A description of the module/package/extension etc.
659
660=item *
ac634a9a 661
2e1d04bc 662A copyright notice - see below.
663
664=item *
ac634a9a 665
2e1d04bc 666Prerequisites - what else you may need to have.
667
668=item *
ac634a9a 669
2e1d04bc 670How to build it - possible changes to Makefile.PL etc.
671
672=item *
ac634a9a 673
2e1d04bc 674How to install it.
675
676=item *
ac634a9a 677
2e1d04bc 678Recent changes in this release, especially incompatibilities
679
680=item *
ac634a9a 681
2e1d04bc 682Changes / enhancements you plan to make in the future.
683
684=back
685
686If the README file seems to be getting too large you may wish to
687split out some of the sections into separate files: INSTALL,
688Copying, ToDo etc.
689
690=over 4
691
692=item Adding a Copyright Notice.
693
ac634a9a 694
2e1d04bc 695How you choose to license your work is a personal decision.
696The general mechanism is to assert your Copyright and then make
697a declaration of how others may copy/use/modify your work.
698
699Perl, for example, is supplied with two types of licence: The GNU
700GPL and The Artistic Licence (see the files README, Copying, and
701Artistic). Larry has good reasons for NOT just using the GNU GPL.
702
703My personal recommendation, out of respect for Larry, Perl, and the
704Perl community at large is to state something simply like:
705
706 Copyright (c) 1995 Your Name. All rights reserved.
707 This program is free software; you can redistribute it and/or
708 modify it under the same terms as Perl itself.
709
710This statement should at least appear in the README file. You may
711also wish to include it in a Copying file and your source files.
712Remember to include the other words in addition to the Copyright.
713
ac634a9a 714=item *
715
716Give the module a version/issue/release number.
2e1d04bc 717
718To be fully compatible with the Exporter and MakeMaker modules you
719should store your module's version number in a non-my package
720variable called $VERSION. This should be a floating point
721number with at least two digits after the decimal (i.e., hundredths,
722e.g, C<$VERSION = "0.01">). Don't use a "1.3.2" style version.
723See L<Exporter> for details.
724
725It may be handy to add a function or method to retrieve the number.
726Use the number in announcements and archive file names when
727releasing the module (ModuleName-1.02.tar.Z).
728See perldoc ExtUtils::MakeMaker.pm for details.
729
ac634a9a 730=item *
731
732How to release and distribute a module.
2e1d04bc 733
734It's good idea to post an announcement of the availability of your
735module (or the module itself if small) to the comp.lang.perl.announce
736Usenet newsgroup. This will at least ensure very wide once-off
737distribution.
738
739If possible, register the module with CPAN. You should
740include details of its location in your announcement.
741
742Some notes about ftp archives: Please use a long descriptive file
743name that includes the version number. Most incoming directories
744will not be readable/listable, i.e., you won't be able to see your
745file after uploading it. Remember to send your email notification
746message as soon as possible after uploading else your file may get
747deleted automatically. Allow time for the file to be processed
748and/or check the file has been processed before announcing its
749location.
750
751FTP Archives for Perl Modules:
752
753Follow the instructions and links on:
754
755 http://www.perl.com/CPAN/modules/00modlist.long.html
756 http://www.perl.com/CPAN/modules/04pause.html
757
758or upload to one of these sites:
759
760 https://pause.kbx.de/pause/
761 http://pause.perl.org/pause/
762
763and notify <modules@perl.org>.
764
765By using the WWW interface you can ask the Upload Server to mirror
766your modules from your ftp or WWW site into your own directory on
767CPAN!
768
769Please remember to send me an updated entry for the Module list!
770
ac634a9a 771=item *
772
773Take care when changing a released module.
2e1d04bc 774
775Always strive to remain compatible with previous released versions.
776Otherwise try to add a mechanism to revert to the
777old behavior if people rely on it. Document incompatible changes.
778
779=back
780
781=back
782
783=head2 Guidelines for Converting Perl 4 Library Scripts into Modules
784
785=over 4
786
ac634a9a 787=item *
788
789There is no requirement to convert anything.
2e1d04bc 790
791If it ain't broke, don't fix it! Perl 4 library scripts should
792continue to work with no problems. You may need to make some minor
793changes (like escaping non-array @'s in double quoted strings) but
794there is no need to convert a .pl file into a Module for just that.
795
ac634a9a 796=item *
797
798Consider the implications.
2e1d04bc 799
800All Perl applications that make use of the script will need to
801be changed (slightly) if the script is converted into a module. Is
802it worth it unless you plan to make other changes at the same time?
803
ac634a9a 804=item *
805
806Make the most of the opportunity.
2e1d04bc 807
808If you are going to convert the script to a module you can use the
809opportunity to redesign the interface. The guidelines for module
810creation above include many of the issues you should consider.
811
ac634a9a 812=item *
813
814The pl2pm utility will get you started.
2e1d04bc 815
816This utility will read *.pl files (given as parameters) and write
817corresponding *.pm files. The pl2pm utilities does the following:
818
819=over 10
820
821=item *
ac634a9a 822
2e1d04bc 823Adds the standard Module prologue lines
824
825=item *
ac634a9a 826
2e1d04bc 827Converts package specifiers from ' to ::
828
829=item *
ac634a9a 830
2e1d04bc 831Converts die(...) to croak(...)
832
833=item *
ac634a9a 834
2e1d04bc 835Several other minor changes
836
837=back
838
839Being a mechanical process pl2pm is not bullet proof. The converted
840code will need careful checking, especially any package statements.
841Don't delete the original .pl file till the new .pm one works!
842
843=back
844
845=head2 Guidelines for Reusing Application Code
846
847=over 4
848
ac634a9a 849=item *
850
851Complete applications rarely belong in the Perl Module Library.
852
853=item *
2e1d04bc 854
ac634a9a 855Many applications contain some Perl code that could be reused.
2e1d04bc 856
857Help save the world! Share your code in a form that makes it easy
858to reuse.
859
ac634a9a 860=item *
861
862Break-out the reusable code into one or more separate module files.
863
864=item *
865
866Take the opportunity to reconsider and redesign the interfaces.
2e1d04bc 867
ac634a9a 868=item *
2e1d04bc 869
ac634a9a 870In some cases the 'application' can then be reduced to a small
2e1d04bc 871
872fragment of code built on top of the reusable modules. In these cases
873the application could invoked as:
874
875 % perl -e 'use Module::Name; method(@ARGV)' ...
876or
877 % perl -mModule::Name ... (in perl5.002 or higher)
878
879=back
880
881=head1 NOTE
882
883Perl does not enforce private and public parts of its modules as you may
884have been used to in other languages like C++, Ada, or Modula-17. Perl
885doesn't have an infatuation with enforced privacy. It would prefer
886that you stayed out of its living room because you weren't invited, not
887because it has a shotgun.
888
889The module and its user have a contract, part of which is common law,
890and part of which is "written". Part of the common law contract is
891that a module doesn't pollute any namespace it wasn't asked to. The
892written contract for the module (A.K.A. documentation) may make other
893provisions. But then you know when you C<use RedefineTheWorld> that
894you're redefining the world and willing to take the consequences.
895EOF
896
897close MANIFEST or warn "$0: failed to close MANIFEST (../MANIFEST): $!";
898close OUT or warn "$0: failed to close OUT (perlmodlib.tmp): $!";
899