This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
better document version check aspect of "use"
[perl5.git] / pod / perlmodlib.PL
CommitLineData
2e1d04bc
JH
1#!../miniperl
2
5b504182
NC
3use strict;
4use warnings;
5
bdba2fe9 6local $ENV{LC_ALL} = 'C';
1fa7ca25 7
f556af6c
NC
8my $Quiet;
9@ARGV = grep { not($_ eq '-q' and $Quiet = 1) } @ARGV;
291c64f4 10
f556af6c
NC
11if (@ARGV) {
12 my $workdir = shift;
13 chdir $workdir
14 or die "Couldn't chdir to '$workdir': $!";
15}
3d7c117d 16require './regen/regen_lib.pl';
4d671226 17
291c64f4
NC
18# MANIFEST itself is Unix style filenames, so we have to assume that Unix style
19# filenames will work.
20
f556af6c
NC
21open MANIFEST, '<', 'MANIFEST'
22 or die "Can't open MANIFEST: $!";
0f6ab019
TI
23my @files =
24 grep !m#/perl.*\.pod#,
25 grep m#(?:\.pm|\.pod|_pm\.PL)#,
26 map {s/\s.*//s; $_}
27 grep { m#^(lib|ext|dist|cpan)/# && !m#/(?:t|demo)/# }
28 <MANIFEST>;
f556af6c
NC
29close MANIFEST
30 or die "$0: failed to close MANIFEST: $!";
31
32my $out = open_new('pod/perlmodlib.pod', undef,
33 {by => "$0 extracting documentation",
34 from => 'the Perl source files'}, 1);
cf9cbb1f
NC
35
36my %exceptions = (
37 'abbrev' => 'Text::Abbrev',
38 'carp' => 'Carp',
39 'getopt' => 'Getopt::Std',
cf9cbb1f
NC
40 'Encode::MIME::NAME' => 'Encode::MIME::Name',
41 'libnetFAQ' => 'Net::libnetFAQ',
4e42dfb1
JB
42);
43
f556af6c
NC
44my (@pragma, @mod);
45
cf9cbb1f 46for my $filename (@files) {
f556af6c
NC
47 unless (open MOD, '<', $filename) {
48 warn "Couldn't open $filename: $!";
e8041d9b 49 next;
4e42dfb1 50 }
4e860d0a 51
5b504182
NC
52 my ($name, $thing);
53 my $foundit = 0;
54 {
55 local $/ = "";
56 while (<MOD>) {
57 next unless /^=head1 NAME/;
58 $foundit++;
59 last;
60 }
61 }
62 unless ($foundit) {
63 warn "$filename missing =head1 NAME (OK if respective .pod exists)\n"
64 unless $Quiet;
65 next;
66 }
67 my $title = <MOD>;
68 chomp $title;
f556af6c
NC
69 close MOD
70 or die "Error closing $filename: $!";
1fa7ca25 71
5b504182 72 ($name, $thing) = split / --? /, $title, 2;
4e42dfb1 73
5b504182
NC
74 unless ($name and $thing) {
75 warn "$filename missing name\n" unless $name;
76 warn "$filename missing thing\n" unless $thing or $Quiet;
77 next;
78 }
79
80 $name =~ s/[^A-Za-z0-9_:\$<>].*//;
81 $name = $exceptions{$name} || $name;
82 $thing =~ s/^perl pragma to //i;
83 $thing = ucfirst $thing;
84 $title = "=item $name\n\n$thing\n\n";
85
86 if ($name =~ /[A-Z]/) {
87 push @mod, $title;
88 } else {
89 push @pragma, $title;
90 }
2e1d04bc
JH
91}
92
cf9cbb1f
NC
93# Much easier to special case it like this than special case the depending on
94# and parsing lib/Config.pod, or special case opening configpm and finding its
95# =head1 (which is not found with the $/="" above)
d72ea276 96push @mod, "=item Config\n\nAccess Perl configuration information\n\n";
cf9cbb1f 97
cf9cbb1f 98
d72ea276
NC
99# The intent of using =cut as the heredoc terminator is to make the whole file
100# parse as (reasonably) sane Pod as-is to anything that attempts to
101# brute-force treat it as such. The content is already useful - this just
102# makes it tidier, by stopping anything doing this mistaking the rest of the
103# Perl code for Pod. eg http://search.cpan.org/dist/perl/pod/perlmodlib.PL
cf9cbb1f 104
f556af6c 105print $out <<'=cut';
2e1d04bc
JH
106=head1 NAME
107
108perlmodlib - constructing new Perl modules and finding existing ones
109
2e1d04bc
JH
110=head1 THE PERL MODULE LIBRARY
111
7ef5744c 112Many modules are included in the Perl distribution. These are described
2e1d04bc 113below, and all end in F<.pm>. You may discover compiled library
7ef5744c 114files (usually ending in F<.so>) or small pieces of modules to be
2e1d04bc
JH
115autoloaded (ending in F<.al>); these were automatically generated
116by the installation process. You may also discover files in the
117library directory that end in either F<.pl> or F<.ph>. These are
118old libraries supplied so that old programs that use them still
119run. The F<.pl> files will all eventually be converted into standard
120modules, and the F<.ph> files made by B<h2ph> will probably end up
121as extension modules made by B<h2xs>. (Some F<.ph> values may
122already be available through the POSIX, Errno, or Fcntl modules.)
123The B<pl2pm> file in the distribution may help in your conversion,
124but it's just a mechanical process and therefore far from bulletproof.
125
126=head2 Pragmatic Modules
127
128They work somewhat like compiler directives (pragmata) in that they
129tend to affect the compilation of your program, and thus will usually
130work well only when used within a C<use>, or C<no>. Most of these
131are lexically scoped, so an inner BLOCK may countermand them
132by saying:
133
134 no integer;
135 no strict 'refs';
136 no warnings;
137
138which lasts until the end of that BLOCK.
139
140Some pragmas are lexically scoped--typically those that affect the
141C<$^H> hints variable. Others affect the current package instead,
142like C<use vars> and C<use subs>, which allow you to predeclare a
143variables or subroutines within a particular I<file> rather than
144just a block. Such declarations are effective for the entire file
145for which they were declared. You cannot rescind them with C<no
146vars> or C<no subs>.
147
148The following pragmas are defined (and have their own documentation).
149
150=over 12
151
d72ea276 152=cut
2e1d04bc 153
f556af6c 154print $out $_ for sort @pragma;
2e1d04bc 155
f556af6c 156print $out <<'=cut';
d72ea276 157
2e1d04bc
JH
158=back
159
160=head2 Standard Modules
161
162Standard, bundled modules are all expected to behave in a well-defined
163manner with respect to namespace pollution because they use the
164Exporter module. See their own documentation for details.
165
7ef5744c
RGS
166It's possible that not all modules listed below are installed on your
167system. For example, the GDBM_File module will not be installed if you
168don't have the gdbm library.
169
2e1d04bc
JH
170=over 12
171
d72ea276 172=cut
2e1d04bc 173
f556af6c 174print $out $_ for sort @mod;
2e1d04bc 175
f556af6c 176print $out <<'=cut', "=cut\n";
d72ea276 177
2e1d04bc
JH
178=back
179
180To find out I<all> modules installed on your system, including
181those without documentation or outside the standard release,
a4373870
CW
182just use the following command (under the default win32 shell,
183double quotes should be used instead of single quotes).
2e1d04bc 184
a4373870
CW
185 % perl -MFile::Find=find -MFile::Spec::Functions -Tlwe \
186 'find { wanted => sub { print canonpath $_ if /\.pm\z/ },
187 no_chdir => 1 }, @INC'
2e1d04bc 188
8518420c 189(The -T is here to prevent '.' from being listed in @INC.)
2e1d04bc
JH
190They should all have their own documentation installed and accessible
191via your system man(1) command. If you do not have a B<find>
192program, you can use the Perl B<find2perl> program instead, which
193generates Perl code as output you can run through perl. If you
194have a B<man> program but it doesn't find your modules, you'll have
195to fix your manpath. See L<perl> for details. If you have no
196system B<man> command, you might try the B<perldoc> program.
197
8518420c
RGS
198Note also that the command C<perldoc perllocal> gives you a (possibly
199incomplete) list of the modules that have been further installed on
200your system. (The perllocal.pod file is updated by the standard MakeMaker
201install process.)
202
2e1d04bc
JH
203=head2 Extension Modules
204
205Extension modules are written in C (or a mix of Perl and C). They
206are usually dynamically loaded into Perl if and when you need them,
da75cd15 207but may also be linked in statically. Supported extension modules
2e1d04bc
JH
208include Socket, Fcntl, and POSIX.
209
210Many popular C extension modules do not come bundled (at least, not
211completely) due to their sizes, volatility, or simply lack of time
212for adequate testing and configuration across the multitude of
213platforms on which Perl was beta-tested. You are encouraged to
214look for them on CPAN (described below), or using web search engines
7ef5744c 215like Alta Vista or Google.
2e1d04bc
JH
216
217=head1 CPAN
218
219CPAN stands for Comprehensive Perl Archive Network; it's a globally
220replicated trove of Perl materials, including documentation, style
221guides, tricks and traps, alternate ports to non-Unix systems and
222occasional binary distributions for these. Search engines for
1577cd80 223CPAN can be found at http://www.cpan.org/
2e1d04bc
JH
224
225Most importantly, CPAN includes around a thousand unbundled modules,
226some of which require a C compiler to build. Major categories of
227modules are:
228
229=over
230
231=item *
ac634a9a 232
2e1d04bc
JH
233Language Extensions and Documentation Tools
234
235=item *
ac634a9a 236
2e1d04bc
JH
237Development Support
238
239=item *
ac634a9a 240
2e1d04bc
JH
241Operating System Interfaces
242
243=item *
ac634a9a 244
2e1d04bc
JH
245Networking, Device Control (modems) and InterProcess Communication
246
247=item *
ac634a9a 248
2e1d04bc
JH
249Data Types and Data Type Utilities
250
251=item *
ac634a9a 252
2e1d04bc
JH
253Database Interfaces
254
255=item *
ac634a9a 256
2e1d04bc
JH
257User Interfaces
258
259=item *
ac634a9a 260
2e1d04bc
JH
261Interfaces to / Emulations of Other Programming Languages
262
263=item *
ac634a9a 264
2e1d04bc
JH
265File Names, File Systems and File Locking (see also File Handles)
266
267=item *
ac634a9a 268
2e1d04bc
JH
269String Processing, Language Text Processing, Parsing, and Searching
270
271=item *
ac634a9a 272
2e1d04bc
JH
273Option, Argument, Parameter, and Configuration File Processing
274
275=item *
ac634a9a 276
2e1d04bc
JH
277Internationalization and Locale
278
279=item *
ac634a9a 280
2e1d04bc
JH
281Authentication, Security, and Encryption
282
283=item *
ac634a9a 284
2e1d04bc
JH
285World Wide Web, HTML, HTTP, CGI, MIME
286
287=item *
ac634a9a 288
2e1d04bc
JH
289Server and Daemon Utilities
290
291=item *
ac634a9a 292
2e1d04bc
JH
293Archiving and Compression
294
295=item *
ac634a9a 296
2e1d04bc
JH
297Images, Pixmap and Bitmap Manipulation, Drawing, and Graphing
298
299=item *
ac634a9a 300
2e1d04bc
JH
301Mail and Usenet News
302
303=item *
ac634a9a 304
2e1d04bc
JH
305Control Flow Utilities (callbacks and exceptions etc)
306
307=item *
ac634a9a 308
2e1d04bc
JH
309File Handle and Input/Output Stream Utilities
310
311=item *
ac634a9a 312
2e1d04bc
JH
313Miscellaneous Modules
314
315=back
316
9d169eb4 317The list of the registered CPAN sites follows.
5df44211
JH
318Please note that the sorting order is alphabetical on fields:
319
320Continent
321 |
322 |-->Country
323 |
324 |-->[state/province]
325 |
326 |-->ftp
327 |
328 |-->[http]
329
330and thus the North American servers happen to be listed between the
331European and the South American sites.
332
9d169eb4 333Registered CPAN sites
2e1d04bc 334
04b029fe
LB
335=for maintainers
336Generated by Porting/make_modlib_cpan.pl
337
4e860d0a
JH
338=head2 Africa
339
340=over 4
341
5df44211 342=item South Africa
4e860d0a 343
04b029fe
LB
344 http://mirror.is.co.za/pub/cpan/
345 ftp://ftp.is.co.za/pub/cpan/
9ed2d9d9
CBW
346 http://cpan.mirror.ac.za/
347 ftp://cpan.mirror.ac.za/
348 http://cpan.saix.net/
04b029fe 349 ftp://ftp.saix.net/pub/CPAN/
9ed2d9d9
CBW
350 http://ftp.wa.co.za/pub/CPAN/
351 ftp://ftp.wa.co.za/pub/CPAN/
352
353=item Uganda
354
355 http://mirror.ucu.ac.ug/cpan/
356
357=item Zimbabwe
358
359 http://mirror.zol.co.zw/CPAN/
360 ftp://mirror.zol.co.zw/CPAN/
4e860d0a
JH
361
362=back
363
364=head2 Asia
365
366=over 4
367
9ed2d9d9 368=item Bangladesh
04b029fe 369
9ed2d9d9
CBW
370 http://mirror.dhakacom.com/CPAN/
371 ftp://mirror.dhakacom.com/CPAN/
04b029fe 372
9ed2d9d9 373=item China
4e860d0a 374
9ed2d9d9 375 http://cpan.communilink.net/
04b029fe
LB
376 http://ftp.cuhk.edu.hk/pub/packages/perl/CPAN/
377 ftp://ftp.cuhk.edu.hk/pub/packages/perl/CPAN/
9ed2d9d9
CBW
378 http://mirrors.hust.edu.cn/CPAN/
379 http://mirrors.neusoft.edu.cn/cpan/
380 http://mirror.lzu.edu.cn/CPAN/
381 http://mirrors.163.com/cpan/
382 http://mirrors.sohu.com/CPAN/
383 http://mirrors.ustc.edu.cn/CPAN/
384 ftp://mirrors.ustc.edu.cn/CPAN/
385 http://mirrors.xmu.edu.cn/CPAN/
386 ftp://mirrors.xmu.edu.cn/CPAN/
387 http://mirrors.zju.edu.cn/CPAN/
c165c82a 388
9d169eb4 389=item India
c165c82a 390
9ed2d9d9 391 http://cpan.excellmedia.net/
04b029fe 392 http://perlmirror.indialinks.com/
c165c82a 393
9d169eb4 394=item Indonesia
c165c82a 395
9ed2d9d9 396 http://kambing.ui.ac.id/cpan/
04b029fe 397 http://cpan.pesat.net.id/
9ed2d9d9
CBW
398 http://mirror.poliwangi.ac.id/CPAN/
399 http://kartolo.sby.datautama.net.id/CPAN/
400 http://mirror.wanxp.id/cpan/
401
402=item Iran
403
404 http://mirror.yazd.ac.ir/cpan/
405
406=item Israel
407
408 http://biocourse.weizmann.ac.il/CPAN/
c165c82a 409
5df44211 410=item Japan
c165c82a 411
9ed2d9d9
CBW
412 http://ftp.jaist.ac.jp/pub/CPAN/
413 ftp://ftp.jaist.ac.jp/pub/CPAN/
414 http://mirror.jre655.com/CPAN/
415 ftp://mirror.jre655.com/CPAN/
04b029fe
LB
416 ftp://ftp.kddilabs.jp/CPAN/
417 http://ftp.nara.wide.ad.jp/pub/CPAN/
418 ftp://ftp.nara.wide.ad.jp/pub/CPAN/
04b029fe
LB
419 http://ftp.riken.jp/lang/CPAN/
420 ftp://ftp.riken.jp/lang/CPAN/
9ed2d9d9 421 ftp://ftp.u-aizu.ac.jp/pub/CPAN/
04b029fe
LB
422 http://ftp.yz.yamagata-u.ac.jp/pub/lang/cpan/
423 ftp://ftp.yz.yamagata-u.ac.jp/pub/lang/cpan/
4e860d0a 424
9ed2d9d9
CBW
425=item Kazakhstan
426
427 http://mirror.neolabs.kz/CPAN/
428 ftp://mirror.neolabs.kz/CPAN/
429
430=item Philippines
431
432 http://mirror.pregi.net/CPAN/
433 ftp://mirror.pregi.net/CPAN/
434 http://mirror.rise.ph/cpan/
435 ftp://mirror.rise.ph/cpan/
436
437=item Qatar
438
439 http://mirror.qnren.qa/CPAN/
440 ftp://mirror.qnren.qa/CPAN/
441
9d169eb4 442=item Republic of Korea
4e860d0a 443
04b029fe
LB
444 http://cpan.mirror.cdnetworks.com/
445 ftp://cpan.mirror.cdnetworks.com/CPAN/
9ed2d9d9
CBW
446 http://ftp.kaist.ac.kr/pub/CPAN/
447 ftp://ftp.kaist.ac.kr/CPAN/
448 http://ftp.kr.freebsd.org/pub/CPAN/
449 ftp://ftp.kr.freebsd.org/pub/CPAN/
450 http://mirror.navercorp.com/CPAN/
451 http://ftp.neowiz.com/CPAN/
452 ftp://ftp.neowiz.com/CPAN/
4e860d0a 453
5df44211 454=item Singapore
4e860d0a 455
04b029fe 456 http://cpan.mirror.choon.net/
9ed2d9d9
CBW
457 http://mirror.0x.sg/CPAN/
458 ftp://mirror.0x.sg/CPAN/
4e860d0a 459
5df44211 460=item Taiwan
4e860d0a 461
9ed2d9d9
CBW
462 http://cpan.cdpa.nsysu.edu.tw/Unix/Lang/CPAN/
463 ftp://cpan.cdpa.nsysu.edu.tw/Unix/Lang/CPAN/
464 http://cpan.stu.edu.tw/
465 ftp://ftp.stu.edu.tw/CPAN/
466 http://ftp.yzu.edu.tw/CPAN/
467 ftp://ftp.yzu.edu.tw/CPAN/
04b029fe
LB
468 http://cpan.nctu.edu.tw/
469 ftp://cpan.nctu.edu.tw/
9ed2d9d9
CBW
470 http://ftp.ubuntu-tw.org/mirror/CPAN/
471 ftp://ftp.ubuntu-tw.org/mirror/CPAN/
9d169eb4
LB
472
473=item Turkey
474
9ed2d9d9
CBW
475 http://cpan.ulak.net.tr/
476 ftp://ftp.ulak.net.tr/pub/perl/CPAN/
477 http://mirror.vit.com.tr/mirror/CPAN/
478 ftp://mirror.vit.com.tr/CPAN/
4e860d0a 479
9ed2d9d9 480=item Viet Nam
4e860d0a 481
9ed2d9d9
CBW
482 http://mirrors.digipower.vn/CPAN/
483 http://mirror.downloadvn.com/cpan/
484 http://mirrors.vinahost.vn/CPAN/
4e860d0a
JH
485
486=back
487
488=head2 Europe
489
490=over 4
491
5df44211 492=item Austria
4e860d0a 493
04b029fe 494 http://cpan.inode.at/
9ed2d9d9
CBW
495 ftp://cpan.inode.at/
496 http://mirror.easyname.at/cpan/
497 ftp://mirror.easyname.at/cpan/
04b029fe
LB
498 http://gd.tuwien.ac.at/languages/perl/CPAN/
499 ftp://gd.tuwien.ac.at/pub/CPAN/
4e860d0a 500
9ed2d9d9
CBW
501=item Belarus
502
503 http://ftp.byfly.by/pub/CPAN/
504 ftp://ftp.byfly.by/pub/CPAN/
505 http://mirror.datacenter.by/pub/CPAN/
506 ftp://mirror.datacenter.by/pub/CPAN/
507
5df44211 508=item Belgium
4e860d0a 509
9ed2d9d9 510 http://ftp.belnet.be/ftp.cpan.org/
04b029fe 511 ftp://ftp.belnet.be/mirror/ftp.cpan.org/
9ed2d9d9
CBW
512 http://cpan.cu.be/
513 http://lib.ugent.be/CPAN/
514 http://cpan.weepeetelecom.be/
4e860d0a 515
7a142657
JH
516=item Bosnia and Herzegovina
517
9ed2d9d9
CBW
518 http://cpan.mirror.ba/
519 ftp://ftp.mirror.ba/CPAN/
7a142657 520
5df44211 521=item Bulgaria
4e860d0a 522
9ed2d9d9
CBW
523 http://mirrors.neterra.net/CPAN/
524 ftp://mirrors.neterra.net/CPAN/
525 http://mirrors.netix.net/CPAN/
526 ftp://mirrors.netix.net/CPAN/
4e860d0a 527
5df44211 528=item Croatia
4e860d0a 529
04b029fe
LB
530 http://ftp.carnet.hr/pub/CPAN/
531 ftp://ftp.carnet.hr/pub/CPAN/
4e860d0a 532
5df44211 533=item Czech Republic
4e860d0a 534
9ed2d9d9
CBW
535 http://mirror.dkm.cz/cpan/
536 ftp://mirror.dkm.cz/cpan/
04b029fe 537 ftp://ftp.fi.muni.cz/pub/CPAN/
9ed2d9d9
CBW
538 http://mirrors.nic.cz/CPAN/
539 ftp://mirrors.nic.cz/pub/CPAN/
540 http://cpan.mirror.vutbr.cz/
541 ftp://mirror.vutbr.cz/cpan/
4e860d0a 542
5df44211 543=item Denmark
4e860d0a 544
04b029fe 545 http://www.cpan.dk/
9ed2d9d9
CBW
546 http://mirrors.dotsrc.org/cpan/
547 ftp://mirrors.dotsrc.org/cpan/
4e860d0a 548
5df44211 549=item Finland
4e860d0a 550
04b029fe 551 ftp://ftp.funet.fi/pub/languages/perl/CPAN/
4e860d0a 552
5df44211 553=item France
c165c82a 554
9ed2d9d9
CBW
555 http://ftp.ciril.fr/pub/cpan/
556 ftp://ftp.ciril.fr/pub/cpan/
04b029fe
LB
557 http://distrib-coffee.ipsl.jussieu.fr/pub/mirrors/cpan/
558 ftp://distrib-coffee.ipsl.jussieu.fr/pub/mirrors/cpan/
9ed2d9d9 559 http://ftp.lip6.fr/pub/perl/CPAN/
04b029fe 560 ftp://ftp.lip6.fr/pub/perl/CPAN/
9ed2d9d9 561 http://mirror.ibcp.fr/pub/CPAN/
04b029fe 562 ftp://ftp.oleane.net/pub/CPAN/
9ed2d9d9
CBW
563 http://cpan.mirrors.ovh.net/ftp.cpan.org/
564 ftp://cpan.mirrors.ovh.net/ftp.cpan.org/
565 http://cpan.enstimac.fr/
c165c82a 566
5df44211 567=item Germany
c165c82a 568
9ed2d9d9
CBW
569 http://mirror.23media.de/cpan/
570 ftp://mirror.23media.de/cpan/
571 http://artfiles.org/cpan.org/
572 ftp://artfiles.org/cpan.org/
573 http://mirror.bibleonline.ru/cpan/
574 http://mirror.checkdomain.de/CPAN/
575 ftp://mirror.checkdomain.de/CPAN/
576 http://cpan.noris.de/
577 http://mirror.de.leaseweb.net/CPAN/
578 ftp://mirror.de.leaseweb.net/CPAN/
579 http://cpan.mirror.euserv.net/
580 ftp://mirror.euserv.net/cpan/
581 http://ftp-stud.hs-esslingen.de/pub/Mirrors/CPAN/
582 ftp://mirror.fraunhofer.de/CPAN/
583 ftp://ftp.freenet.de/pub/ftp.cpan.org/pub/CPAN/
04b029fe
LB
584 http://ftp.hosteurope.de/pub/CPAN/
585 ftp://ftp.hosteurope.de/pub/CPAN/
9ed2d9d9 586 ftp://ftp.fu-berlin.de/unix/languages/perl/
04b029fe
LB
587 http://ftp.gwdg.de/pub/languages/perl/CPAN/
588 ftp://ftp.gwdg.de/pub/languages/perl/CPAN/
9ed2d9d9
CBW
589 http://ftp.hawo.stw.uni-erlangen.de/CPAN/
590 ftp://ftp.hawo.stw.uni-erlangen.de/CPAN/
04b029fe
LB
591 http://cpan.mirror.iphh.net/
592 ftp://cpan.mirror.iphh.net/pub/CPAN/
9ed2d9d9
CBW
593 ftp://ftp.mpi-inf.mpg.de/pub/perl/CPAN/
594 http://cpan.netbet.org/
595 http://mirror.netcologne.de/cpan/
596 ftp://mirror.netcologne.de/cpan/
04b029fe 597 ftp://mirror.petamem.com/CPAN/
9ed2d9d9
CBW
598 http://www.planet-elektronik.de/CPAN/
599 http://ftp.halifax.rwth-aachen.de/cpan/
600 ftp://ftp.halifax.rwth-aachen.de/cpan/
601 http://mirror.softaculous.com/cpan/
602 http://ftp.u-tx.net/CPAN/
603 ftp://ftp.u-tx.net/CPAN/
604 http://mirror.reismil.ch/CPAN/
4e860d0a 605
5df44211 606=item Greece
4e860d0a 607
9ed2d9d9 608 http://cpan.cc.uoc.gr/mirrors/CPAN/
04b029fe 609 ftp://ftp.cc.uoc.gr/mirrors/CPAN/
9ed2d9d9
CBW
610 http://ftp.ntua.gr/pub/lang/perl/
611 ftp://ftp.ntua.gr/pub/lang/perl/
4e860d0a 612
5df44211 613=item Hungary
4e860d0a 614
9ed2d9d9 615 http://mirror.met.hu/CPAN/
4e860d0a 616
5df44211 617=item Ireland
4e860d0a 618
9ed2d9d9
CBW
619 http://ftp.heanet.ie/mirrors/ftp.perl.org/pub/CPAN/
620 ftp://ftp.heanet.ie/mirrors/ftp.perl.org/pub/CPAN/
4e860d0a 621
5df44211 622=item Italy
4e860d0a 623
04b029fe 624 http://bo.mirror.garr.it/mirrors/CPAN/
9ed2d9d9 625 ftp://ftp.eutelia.it/CPAN_Mirror/
04b029fe
LB
626 http://cpan.panu.it/
627 ftp://ftp.panu.it/pub/mirrors/perl/CPAN/
9ed2d9d9 628 http://cpan.muzzy.it/
4e860d0a 629
5df44211 630=item Latvia
4e860d0a 631
04b029fe 632 http://kvin.lv/pub/CPAN/
4e860d0a 633
5df44211 634=item Lithuania
4e860d0a 635
04b029fe
LB
636 http://ftp.litnet.lt/pub/CPAN/
637 ftp://ftp.litnet.lt/pub/CPAN/
9d169eb4 638
9ed2d9d9 639=item Moldova
9d169eb4 640
9ed2d9d9
CBW
641 http://mirror.as43289.net/pub/CPAN/
642 ftp://mirror.as43289.net/pub/CPAN/
4e860d0a 643
5df44211 644=item Netherlands
4e860d0a 645
9ed2d9d9
CBW
646 http://cpan.cs.uu.nl/
647 ftp://ftp.cs.uu.nl/pub/CPAN/
648 http://mirror.nl.leaseweb.net/CPAN/
649 ftp://mirror.nl.leaseweb.net/CPAN/
650 http://ftp.nluug.nl/languages/perl/CPAN/
651 ftp://ftp.nluug.nl/pub/languages/perl/CPAN/
652 http://mirror.transip.net/CPAN/
653 ftp://mirror.transip.net/CPAN/
654 http://cpan.mirror.triple-it.nl/
655 http://ftp.tudelft.nl/cpan/
656 ftp://ftp.tudelft.nl/pub/CPAN/
04b029fe 657 ftp://download.xs4all.nl/pub/mirror/CPAN/
4e860d0a 658
5df44211
JH
659=item Norway
660
9ed2d9d9
CBW
661 http://cpan.uib.no/
662 ftp://cpan.uib.no/pub/CPAN/
663 ftp://ftp.uninett.no/pub/languages/perl/CPAN/
664 http://cpan.vianett.no/
5df44211
JH
665
666=item Poland
667
9ed2d9d9
CBW
668 http://ftp.agh.edu.pl/CPAN/
669 ftp://ftp.agh.edu.pl/CPAN/
670 http://ftp.piotrkosoft.net/pub/mirrors/CPAN/
04b029fe 671 ftp://ftp.piotrkosoft.net/pub/mirrors/CPAN/
04b029fe 672 ftp://ftp.ps.pl/pub/CPAN/
9ed2d9d9 673 http://sunsite.icm.edu.pl/pub/CPAN/
04b029fe 674 ftp://sunsite.icm.edu.pl/pub/CPAN/
5df44211
JH
675
676=item Portugal
677
04b029fe 678 http://cpan.dcc.fc.up.pt/
9ed2d9d9
CBW
679 http://mirrors.fe.up.pt/pub/CPAN/
680 http://cpan.perl-hackers.net/
681 http://cpan.perl.pt/
4e860d0a 682
5df44211 683=item Romania
4e860d0a 684
9ed2d9d9
CBW
685 http://mirrors.hostingromania.ro/cpan.org/
686 ftp://ftp.lug.ro/CPAN/
687 http://mirrors.m247.ro/CPAN/
688 http://mirrors.evowise.com/CPAN/
689 http://mirrors.teentelecom.net/CPAN/
690 ftp://mirrors.teentelecom.net/CPAN/
04b029fe 691 http://mirrors.xservers.ro/CPAN/
4e860d0a 692
9ed2d9d9 693=item Russian Federation
4e860d0a 694
04b029fe
LB
695 ftp://ftp.aha.ru/CPAN/
696 http://cpan.rinet.ru/
697 ftp://cpan.rinet.ru/pub/mirror/CPAN/
9ed2d9d9 698 http://cpan-mirror.rbc.ru/pub/CPAN/
04b029fe 699 http://mirror.rol.ru/CPAN/
9ed2d9d9
CBW
700 http://cpan.uni-altai.ru/
701 http://cpan.webdesk.ru/
702 ftp://cpan.webdesk.ru/cpan/
703 http://mirror.yandex.ru/mirrors/cpan/
704 ftp://mirror.yandex.ru/mirrors/cpan/
705
706=item Serbia
707
708 http://mirror.sbb.rs/CPAN/
709 ftp://mirror.sbb.rs/CPAN/
4e860d0a 710
5df44211 711=item Slovakia
4e860d0a 712
9ed2d9d9
CBW
713 http://cpan.lnx.sk/
714 http://tux.rainside.sk/CPAN/
715 ftp://tux.rainside.sk/CPAN/
4e860d0a 716
5df44211 717=item Slovenia
4e860d0a 718
9ed2d9d9
CBW
719 http://ftp.arnes.si/software/perl/CPAN/
720 ftp://ftp.arnes.si/software/perl/CPAN/
4e860d0a 721
5df44211 722=item Spain
4e860d0a 723
9ed2d9d9 724 http://mirrors.evowise.com/CPAN/
04b029fe 725 http://osl.ugr.es/CPAN/
9ed2d9d9 726 http://ftp.rediris.es/mirror/CPAN/
04b029fe 727 ftp://ftp.rediris.es/mirror/CPAN/
4e860d0a 728
5df44211 729=item Sweden
4e860d0a 730
9ed2d9d9
CBW
731 http://ftp.acc.umu.se/mirror/CPAN/
732 ftp://ftp.acc.umu.se/mirror/CPAN/
4e860d0a 733
5df44211 734=item Switzerland
4e860d0a 735
9ed2d9d9 736 http://www.pirbot.com/mirrors/cpan/
04b029fe
LB
737 http://mirror.switch.ch/ftp/mirror/CPAN/
738 ftp://mirror.switch.ch/mirror/CPAN/
c165c82a 739
5df44211 740=item Ukraine
c165c82a 741
9ed2d9d9
CBW
742 http://cpan.ip-connect.vn.ua/
743 ftp://cpan.ip-connect.vn.ua/mirror/cpan/
c165c82a 744
5df44211 745=item United Kingdom
d4858812 746
04b029fe
LB
747 http://cpan.mirror.anlx.net/
748 ftp://ftp.mirror.anlx.net/CPAN/
749 http://mirror.bytemark.co.uk/CPAN/
750 ftp://mirror.bytemark.co.uk/CPAN/
9ed2d9d9 751 http://mirrors.coreix.net/CPAN/
04b029fe 752 http://cpan.etla.org/
9ed2d9d9
CBW
753 ftp://cpan.etla.org/pub/CPAN/
754 http://cpan.cpantesters.org/
755 http://mirror.sax.uk.as61049.net/CPAN/
04b029fe 756 http://mirror.sov.uk.goscomb.net/CPAN/
9ed2d9d9
CBW
757 http://www.mirrorservice.org/sites/cpan.perl.org/CPAN/
758 ftp://ftp.mirrorservice.org/sites/cpan.perl.org/CPAN/
759 http://mirror.ox.ac.uk/sites/www.cpan.org/
760 ftp://mirror.ox.ac.uk/sites/www.cpan.org/
04b029fe
LB
761 http://ftp.ticklers.org/pub/CPAN/
762 ftp://ftp.ticklers.org/pub/CPAN/
763 http://cpan.mirrors.uk2.net/
764 ftp://mirrors.uk2.net/pub/CPAN/
9ed2d9d9 765 http://mirror.ukhost4u.com/CPAN/
d4858812 766
4e860d0a
JH
767=back
768
769=head2 North America
770
771=over 4
772
9d169eb4 773=item Canada
4e860d0a 774
04b029fe
LB
775 http://CPAN.mirror.rafal.ca/
776 ftp://CPAN.mirror.rafal.ca/pub/CPAN/
9ed2d9d9
CBW
777 http://mirror.csclub.uwaterloo.ca/CPAN/
778 ftp://mirror.csclub.uwaterloo.ca/CPAN/
779 http://mirrors.gossamer-threads.com/CPAN/
780 http://mirror.its.dal.ca/cpan/
781 ftp://mirror.its.dal.ca/cpan/
782 ftp://ftp.ottix.net/pub/CPAN/
783
784=item Costa Rica
785
786 http://mirrors.ucr.ac.cr/CPAN/
7a142657 787
5df44211 788=item Mexico
c165c82a 789
04b029fe
LB
790 http://www.msg.com.mx/CPAN/
791 ftp://ftp.msg.com.mx/pub/CPAN/
c165c82a 792
5c5c2539 793=item United States
d4858812 794
7a142657 795=over 8
4e860d0a 796
5df44211 797=item Alabama
4e860d0a 798
9ed2d9d9 799 http://mirror.teklinks.com/CPAN/
04b029fe
LB
800
801=item Arizona
802
9ed2d9d9
CBW
803 http://mirror.n5tech.com/CPAN/
804 http://mirrors.namecheap.com/CPAN/
805 ftp://mirrors.namecheap.com/CPAN/
4e860d0a 806
5df44211 807=item California
4e860d0a 808
04b029fe 809 http://cpan.develooper.com/
9ed2d9d9
CBW
810 http://httpupdate127.cpanel.net/CPAN/
811 http://mirrors.sonic.net/cpan/
812 ftp://mirrors.sonic.net/cpan/
04b029fe 813 http://www.perl.com/CPAN/
9ed2d9d9 814 http://cpan.yimg.com/
4e860d0a 815
9d169eb4 816=item Idaho
4e860d0a 817
9ed2d9d9
CBW
818 http://mirrors.syringanetworks.net/CPAN/
819 ftp://mirrors.syringanetworks.net/CPAN/
4e860d0a 820
9d169eb4 821=item Illinois
c165c82a 822
04b029fe 823 http://cpan.mirrors.hoobly.com/
9ed2d9d9
CBW
824 http://mirror.team-cymru.org/CPAN/
825 ftp://mirror.team-cymru.org/CPAN/
c165c82a 826
5df44211 827=item Indiana
4e860d0a 828
04b029fe
LB
829 http://cpan.netnitco.net/
830 ftp://cpan.netnitco.net/pub/mirrors/CPAN/
9ed2d9d9
CBW
831 ftp://ftp.uwsg.iu.edu/pub/perl/CPAN/
832
833=item Kansas
834
835 http://mirrors.concertpass.com/cpan/
4e860d0a 836
5df44211 837=item Massachusetts
4e860d0a 838
04b029fe 839 http://mirrors.ccs.neu.edu/CPAN/
4e860d0a 840
5df44211 841=item Michigan
4e860d0a 842
9ed2d9d9
CBW
843 http://cpan.cse.msu.edu/
844 ftp://cpan.cse.msu.edu/
845 http://httpupdate118.cpanel.net/CPAN/
846 http://mirrors-usa.go-parts.com/cpan/
847 http://ftp.wayne.edu/CPAN/
848 ftp://ftp.wayne.edu/CPAN/
4e860d0a 849
9ed2d9d9 850=item New Hampshire
5c5c2539 851
9ed2d9d9 852 http://mirror.metrocast.net/cpan/
5c5c2539 853
5df44211 854=item New Jersey
4e860d0a 855
04b029fe
LB
856 http://mirror.datapipe.net/CPAN/
857 ftp://mirror.datapipe.net/pub/CPAN/
9ed2d9d9
CBW
858 http://www.hoovism.com/CPAN/
859 ftp://ftp.hoovism.com/CPAN/
860 http://cpan.mirror.nac.net/
4e860d0a 861
5df44211 862=item New York
4e860d0a 863
04b029fe
LB
864 http://mirror.cc.columbia.edu/pub/software/cpan/
865 ftp://mirror.cc.columbia.edu/pub/software/cpan/
866 http://cpan.belfry.net/
867 http://cpan.erlbaum.net/
868 ftp://cpan.erlbaum.net/CPAN/
869 http://cpan.hexten.net/
870 ftp://cpan.hexten.net/
9ed2d9d9
CBW
871 http://mirror.nyi.net/CPAN/
872 ftp://mirror.nyi.net/pub/CPAN/
873 http://noodle.portalus.net/CPAN/
874 ftp://noodle.portalus.net/CPAN/
875 http://mirrors.rit.edu/CPAN/
876 ftp://mirrors.rit.edu/CPAN/
4e860d0a 877
5df44211 878=item North Carolina
4e860d0a 879
9ed2d9d9
CBW
880 http://httpupdate140.cpanel.net/CPAN/
881 http://mirrors.ibiblio.org/CPAN/
4e860d0a 882
5df44211 883=item Oregon
4e860d0a 884
04b029fe
LB
885 http://ftp.osuosl.org/pub/CPAN/
886 ftp://ftp.osuosl.org/pub/CPAN/
9ed2d9d9 887 http://mirror.uoregon.edu/CPAN/
4e860d0a 888
5df44211 889=item Pennsylvania
4e860d0a 890
04b029fe
LB
891 http://cpan.pair.com/
892 ftp://cpan.pair.com/pub/CPAN/
9ed2d9d9 893 http://cpan.mirrors.ionfish.org/
9d169eb4
LB
894
895=item South Carolina
896
04b029fe 897 http://cpan.mirror.clemson.edu/
4e860d0a 898
5df44211 899=item Texas
4e860d0a 900
9ed2d9d9 901 http://mirror.uta.edu/CPAN/
4e860d0a 902
5df44211 903=item Utah
4e860d0a 904
9ed2d9d9
CBW
905 http://cpan.cs.utah.edu/
906 ftp://cpan.cs.utah.edu/CPAN/
04b029fe 907 ftp://mirror.xmission.com/CPAN/
4e860d0a 908
5df44211 909=item Virginia
4e860d0a 910
9ed2d9d9 911 http://mirror.cogentco.com/pub/CPAN/
04b029fe 912 ftp://mirror.cogentco.com/pub/CPAN/
9ed2d9d9
CBW
913 http://mirror.jmu.edu/pub/CPAN/
914 ftp://mirror.jmu.edu/pub/CPAN/
915 http://mirror.us.leaseweb.net/CPAN/
916 ftp://mirror.us.leaseweb.net/CPAN/
4e860d0a 917
5c5c2539 918=item Washington
4e860d0a 919
04b029fe
LB
920 http://cpan.llarian.net/
921 ftp://cpan.llarian.net/pub/CPAN/
d4858812 922
5df44211 923=item Wisconsin
d4858812 924
9ed2d9d9
CBW
925 http://cpan.mirrors.tds.net/
926 ftp://cpan.mirrors.tds.net/pub/CPAN/
4e860d0a
JH
927
928=back
929
5c5c2539
JH
930=back
931
4e860d0a
JH
932=head2 Oceania
933
934=over 4
935
5df44211 936=item Australia
4e860d0a 937
9ed2d9d9
CBW
938 http://mirror.as24220.net/pub/cpan/
939 ftp://mirror.as24220.net/pub/cpan/
940 http://cpan.mirrors.ilisys.com.au/
941 http://cpan.mirror.digitalpacific.com.au/
04b029fe 942 ftp://mirror.internode.on.net/pub/cpan/
9ed2d9d9
CBW
943 http://mirror.optusnet.com.au/CPAN/
944 http://cpan.mirror.serversaustralia.com.au/
945 http://cpan.uberglobalmirror.com/
946 http://mirror.waia.asn.au/pub/cpan/
947
948=item New Caledonia
949
950 http://cpan.lagoon.nc/pub/CPAN/
951 ftp://cpan.lagoon.nc/pub/CPAN/
952 http://cpan.nautile.nc/CPAN/
953 ftp://cpan.nautile.nc/CPAN/
4e860d0a 954
5df44211 955=item New Zealand
d4858812 956
04b029fe 957 ftp://ftp.auckland.ac.nz/pub/perl/CPAN/
04b029fe
LB
958 http://cpan.catalyst.net.nz/CPAN/
959 ftp://cpan.catalyst.net.nz/pub/CPAN/
9ed2d9d9
CBW
960 http://cpan.inspire.net.nz/
961 ftp://cpan.inspire.net.nz/cpan/
962 http://mirror.webtastix.net/CPAN/
963 ftp://mirror.webtastix.net/CPAN/
4e860d0a
JH
964
965=back
966
967=head2 South America
968
969=over 4
970
5df44211 971=item Argentina
4e860d0a 972
9ed2d9d9 973 http://cpan.mmgdesigns.com.ar/
4e860d0a 974
5df44211 975=item Brazil
4e860d0a 976
04b029fe 977 http://cpan.kinghost.net/
9ed2d9d9
CBW
978 http://linorg.usp.br/CPAN/
979 http://mirror.nbtelecom.com.br/CPAN/
4e860d0a 980
5df44211 981=item Chile
4e860d0a 982
04b029fe
LB
983 http://cpan.dcc.uchile.cl/
984 ftp://cpan.dcc.uchile.cl/pub/lang/cpan/
9d169eb4 985
2e1d04bc
JH
986=back
987
5df44211
JH
988=head2 RSYNC Mirrors
989
9ed2d9d9
CBW
990 rsync://ftp.is.co.za/IS-Mirror/ftp.cpan.org/
991 rsync://mirror.ac.za/CPAN/
992 rsync://mirror.zol.co.zw/CPAN/
993 rsync://mirror.dhakacom.com/CPAN/
994 rsync://mirrors.ustc.edu.cn/CPAN/
995 rsync://mirrors.xmu.edu.cn/CPAN/
996 rsync://kambing.ui.ac.id/CPAN/
997 rsync://ftp.jaist.ac.jp/pub/CPAN/
998 rsync://mirror.jre655.com/CPAN/
999 rsync://ftp.kddilabs.jp/cpan/
1000 rsync://ftp.nara.wide.ad.jp/cpan/
1001 rsync://ftp.riken.jp/cpan/
1002 rsync://mirror.neolabs.kz/CPAN/
1003 rsync://mirror.qnren.qa/CPAN/
1004 rsync://ftp.neowiz.com/CPAN/
1005 rsync://mirror.0x.sg/CPAN/
1006 rsync://ftp.yzu.edu.tw/pub/CPAN/
1007 rsync://ftp.ubuntu-tw.org/CPAN/
1008 rsync://mirrors.digipower.vn/CPAN/
1009 rsync://cpan.inode.at/CPAN/
1010 rsync://ftp.byfly.by/CPAN/
1011 rsync://mirror.datacenter.by/CPAN/
1012 rsync://ftp.belnet.be/cpan/
1013 rsync://cpan.mirror.ba/CPAN/
1014 rsync://mirrors.neterra.net/CPAN/
1015 rsync://mirrors.netix.net/CPAN/
1016 rsync://mirror.dkm.cz/cpan/
1017 rsync://mirrors.nic.cz/CPAN/
1018 rsync://cpan.mirror.vutbr.cz/cpan/
1019 rsync://rsync.nic.funet.fi/CPAN/
1020 rsync://ftp.ciril.fr/pub/cpan/
1021 rsync://distrib-coffee.ipsl.jussieu.fr/pub/mirrors/cpan/
1022 rsync://cpan.mirrors.ovh.net/CPAN/
1023 rsync://mirror.de.leaseweb.net/CPAN/
1024 rsync://mirror.euserv.net/cpan/
1025 rsync://ftp-stud.hs-esslingen.de/CPAN/
1026 rsync://ftp.gwdg.de/pub/languages/perl/CPAN/
1027 rsync://ftp.hawo.stw.uni-erlangen.de/CPAN/
1028 rsync://cpan.mirror.iphh.net/CPAN/
1029 rsync://mirror.netcologne.de/cpan/
1030 rsync://ftp.halifax.rwth-aachen.de/cpan/
1031 rsync://ftp.ntua.gr/CPAN/
1032 rsync://mirror.met.hu/CPAN/
1033 rsync://ftp.heanet.ie/mirrors/ftp.perl.org/pub/CPAN/
1034 rsync://rsync.panu.it/CPAN/
1035 rsync://mirror.as43289.net/CPAN/
1036 rsync://rsync.cs.uu.nl/CPAN/
1037 rsync://mirror.nl.leaseweb.net/CPAN/
1038 rsync://ftp.nluug.nl/CPAN/
1039 rsync://mirror.transip.net/CPAN/
1040 rsync://cpan.uib.no/cpan/
1041 rsync://cpan.vianett.no/CPAN/
1042 rsync://cpan.perl-hackers.net/CPAN/
1043 rsync://cpan.perl.pt/cpan/
1044 rsync://mirrors.m247.ro/CPAN/
1045 rsync://mirrors.teentelecom.net/CPAN/
1046 rsync://cpan.webdesk.ru/CPAN/
1047 rsync://mirror.yandex.ru/mirrors/cpan/
1048 rsync://mirror.sbb.rs/CPAN/
1049 rsync://ftp.acc.umu.se/mirror/CPAN/
1050 rsync://rsync.pirbot.com/ftp/cpan/
1051 rsync://cpan.ip-connect.vn.ua/CPAN/
1052 rsync://rsync.mirror.anlx.net/CPAN/
1053 rsync://mirror.bytemark.co.uk/CPAN/
1054 rsync://mirror.sax.uk.as61049.net/CPAN/
1055 rsync://rsync.mirrorservice.org/cpan.perl.org/CPAN/
1056 rsync://ftp.ticklers.org/CPAN/
1057 rsync://mirrors.uk2.net/CPAN/
1058 rsync://CPAN.mirror.rafal.ca/CPAN/
1059 rsync://mirror.csclub.uwaterloo.ca/CPAN/
1060 rsync://mirrors.namecheap.com/CPAN/
1061 rsync://mirrors.syringanetworks.net/CPAN/
1062 rsync://mirror.team-cymru.org/CPAN/
1063 rsync://debian.cse.msu.edu/cpan/
1064 rsync://mirrors-usa.go-parts.com/mirrors/cpan/
1065 rsync://rsync.hoovism.com/CPAN/
1066 rsync://mirror.cc.columbia.edu/cpan/
1067 rsync://noodle.portalus.net/CPAN/
1068 rsync://mirrors.rit.edu/cpan/
1069 rsync://mirrors.ibiblio.org/CPAN/
1070 rsync://cpan.pair.com/CPAN/
1071 rsync://cpan.cs.utah.edu/CPAN/
1072 rsync://mirror.cogentco.com/CPAN/
1073 rsync://mirror.jmu.edu/CPAN/
1074 rsync://mirror.us.leaseweb.net/CPAN/
1075 rsync://cpan.mirror.digitalpacific.com.au/cpan/
1076 rsync://mirror.internode.on.net/cpan/
1077 rsync://uberglobalmirror.com/cpan/
1078 rsync://cpan.lagoon.nc/cpan/
1079 rsync://mirrors.mmgdesigns.com.ar/CPAN/
1080
5df44211 1081
2e1d04bc 1082For an up-to-date listing of CPAN sites,
9ed2d9d9 1083see L<http://www.cpan.org/SITES> or L<ftp://www.cpan.org/SITES>.
2e1d04bc
JH
1084
1085=head1 Modules: Creation, Use, and Abuse
1086
1087(The following section is borrowed directly from Tim Bunce's modules
1088file, available at your nearest CPAN site.)
1089
1090Perl implements a class using a package, but the presence of a
1091package doesn't imply the presence of a class. A package is just a
1092namespace. A class is a package that provides subroutines that can be
1093used as methods. A method is just a subroutine that expects, as its
1094first argument, either the name of a package (for "static" methods),
1095or a reference to something (for "virtual" methods).
1096
1097A module is a file that (by convention) provides a class of the same
1098name (sans the .pm), plus an import method in that class that can be
1099called to fetch exported symbols. This module may implement some of
1100its methods by loading dynamic C or C++ objects, but that should be
1101totally transparent to the user of the module. Likewise, the module
1102might set up an AUTOLOAD function to slurp in subroutine definitions on
1103demand, but this is also transparent. Only the F<.pm> file is required to
82e1c0d9 1104exist. See L<perlsub>, L<perlobj>, and L<AutoLoader> for details about
2e1d04bc
JH
1105the AUTOLOAD mechanism.
1106
1107=head2 Guidelines for Module Creation
1108
1109=over 4
1110
ac634a9a
JH
1111=item *
1112
1113Do similar modules already exist in some form?
2e1d04bc
JH
1114
1115If so, please try to reuse the existing modules either in whole or
1116by inheriting useful features into a new class. If this is not
1117practical try to get together with the module authors to work on
1118extending or enhancing the functionality of the existing modules.
1119A perfect example is the plethora of packages in perl4 for dealing
1120with command line options.
1121
1122If you are writing a module to expand an already existing set of
1123modules, please coordinate with the author of the package. It
1124helps if you follow the same naming scheme and module interaction
1125scheme as the original author.
1126
ac634a9a
JH
1127=item *
1128
1129Try to design the new module to be easy to extend and reuse.
2e1d04bc
JH
1130
1131Try to C<use warnings;> (or C<use warnings qw(...);>).
1132Remember that you can add C<no warnings qw(...);> to individual blocks
1133of code that need less warnings.
1134
1135Use blessed references. Use the two argument form of bless to bless
1136into the class name given as the first parameter of the constructor,
1137e.g.,:
1138
1139 sub new {
1140 my $class = shift;
1141 return bless {}, $class;
1142 }
1143
1144or even this if you'd like it to be used as either a static
1145or a virtual method.
1146
1147 sub new {
1148 my $self = shift;
1149 my $class = ref($self) || $self;
1150 return bless {}, $class;
1151 }
1152
1153Pass arrays as references so more parameters can be added later
1154(it's also faster). Convert functions into methods where
1155appropriate. Split large methods into smaller more flexible ones.
1156Inherit methods from other modules if appropriate.
1157
1158Avoid class name tests like: C<die "Invalid" unless ref $ref eq 'FOO'>.
1159Generally you can delete the C<eq 'FOO'> part with no harm at all.
1160Let the objects look after themselves! Generally, avoid hard-wired
1161class names as far as possible.
1162
1163Avoid C<< $r->Class::func() >> where using C<@ISA=qw(... Class ...)> and
82e1c0d9 1164C<< $r->func() >> would work.
2e1d04bc
JH
1165
1166Use autosplit so little used or newly added functions won't be a
1167burden to programs that don't use them. Add test functions to
1168the module after __END__ either using AutoSplit or by saying:
1169
1170 eval join('',<main::DATA>) || die $@ unless caller();
1171
1172Does your module pass the 'empty subclass' test? If you say
1173C<@SUBCLASS::ISA = qw(YOURCLASS);> your applications should be able
1174to use SUBCLASS in exactly the same way as YOURCLASS. For example,
63acfd00 1175does your application still work if you change: C<< $obj = YOURCLASS->new(); >>
1176into: C<< $obj = SUBCLASS->new(); >> ?
2e1d04bc
JH
1177
1178Avoid keeping any state information in your packages. It makes it
1179difficult for multiple other packages to use yours. Keep state
1180information in objects.
1181
1182Always use B<-w>.
1183
1184Try to C<use strict;> (or C<use strict qw(...);>).
1185Remember that you can add C<no strict qw(...);> to individual blocks
1186of code that need less strictness.
1187
1188Always use B<-w>.
1189
ba555bf5 1190Follow the guidelines in L<perlstyle>.
2e1d04bc
JH
1191
1192Always use B<-w>.
1193
ac634a9a
JH
1194=item *
1195
1196Some simple style guidelines
2e1d04bc
JH
1197
1198The perlstyle manual supplied with Perl has many helpful points.
1199
1200Coding style is a matter of personal taste. Many people evolve their
1201style over several years as they learn what helps them write and
1202maintain good code. Here's one set of assorted suggestions that
1203seem to be widely used by experienced developers:
1204
1205Use underscores to separate words. It is generally easier to read
1206$var_names_like_this than $VarNamesLikeThis, especially for
1207non-native speakers of English. It's also a simple rule that works
1208consistently with VAR_NAMES_LIKE_THIS.
1209
1210Package/Module names are an exception to this rule. Perl informally
1211reserves lowercase module names for 'pragma' modules like integer
1212and strict. Other modules normally begin with a capital letter and
1213use mixed case with no underscores (need to be short and portable).
1214
1215You may find it helpful to use letter case to indicate the scope
1216or nature of a variable. For example:
1217
1218 $ALL_CAPS_HERE constants only (beware clashes with Perl vars)
1219 $Some_Caps_Here package-wide global/static
1220 $no_caps_here function scope my() or local() variables
1221
1222Function and method names seem to work best as all lowercase.
1223e.g., C<< $obj->as_string() >>.
1224
1225You can use a leading underscore to indicate that a variable or
1226function should not be used outside the package that defined it.
1227
ac634a9a
JH
1228=item *
1229
1230Select what to export.
2e1d04bc
JH
1231
1232Do NOT export method names!
1233
1234Do NOT export anything else by default without a good reason!
1235
1236Exports pollute the namespace of the module user. If you must
1237export try to use @EXPORT_OK in preference to @EXPORT and avoid
1238short or common names to reduce the risk of name clashes.
1239
1240Generally anything not exported is still accessible from outside the
1241module using the ModuleName::item_name (or C<< $blessed_ref->method >>)
1242syntax. By convention you can use a leading underscore on names to
1243indicate informally that they are 'internal' and not for public use.
1244
1245(It is actually possible to get private functions by saying:
1246C<my $subref = sub { ... }; &$subref;>. But there's no way to call that
1247directly as a method, because a method must have a name in the symbol
1248table.)
1249
1250As a general rule, if the module is trying to be object oriented
1251then export nothing. If it's just a collection of functions then
1252@EXPORT_OK anything but use @EXPORT with caution.
1253
ac634a9a
JH
1254=item *
1255
1256Select a name for the module.
2e1d04bc
JH
1257
1258This name should be as descriptive, accurate, and complete as
1259possible. Avoid any risk of ambiguity. Always try to use two or
1260more whole words. Generally the name should reflect what is special
1261about what the module does rather than how it does it. Please use
1262nested module names to group informally or categorize a module.
1263There should be a very good reason for a module not to have a nested name.
1264Module names should begin with a capital letter.
1265
1266Having 57 modules all called Sort will not make life easy for anyone
1267(though having 23 called Sort::Quick is only marginally better :-).
1268Imagine someone trying to install your module alongside many others.
2e1d04bc
JH
1269
1270If you are developing a suite of related modules/classes it's good
1271practice to use nested classes with a common prefix as this will
1272avoid namespace clashes. For example: Xyz::Control, Xyz::View,
1273Xyz::Model etc. Use the modules in this list as a naming guide.
1274
1275If adding a new module to a set, follow the original author's
1276standards for naming modules and the interface to methods in
1277those modules.
1278
4844a3be
SP
1279If developing modules for private internal or project specific use,
1280that will never be released to the public, then you should ensure
1281that their names will not clash with any future public module. You
1282can do this either by using the reserved Local::* category or by
1283using a category name that includes an underscore like Foo_Corp::*.
1284
2e1d04bc
JH
1285To be portable each component of a module name should be limited to
128611 characters. If it might be used on MS-DOS then try to ensure each is
1287unique in the first 8 characters. Nested modules make this easier.
1288
f94c6c53
JK
1289For additional guidance on the naming of modules, please consult:
1290
1291 http://pause.perl.org/pause/query?ACTION=pause_namingmodules
1292
1293or send mail to the <module-authors@perl.org> mailing list.
1294
ac634a9a
JH
1295=item *
1296
1297Have you got it right?
2e1d04bc
JH
1298
1299How do you know that you've made the right decisions? Have you
1300picked an interface design that will cause problems later? Have
1301you picked the most appropriate name? Do you have any questions?
1302
1303The best way to know for sure, and pick up many helpful suggestions,
f94c6c53
JK
1304is to ask someone who knows. The <module-authors@perl.org> mailing list
1305is useful for this purpose; it's also accessible via news interface as
1306perl.module-authors at nntp.perl.org.
2e1d04bc
JH
1307
1308All you need to do is post a short summary of the module, its
1309purpose and interfaces. A few lines on each of the main methods is
1310probably enough. (If you post the whole module it might be ignored
1311by busy people - generally the very people you want to read it!)
1312
1313Don't worry about posting if you can't say when the module will be
1314ready - just say so in the message. It might be worth inviting
1315others to help you, they may be able to complete it for you!
1316
ac634a9a
JH
1317=item *
1318
1319README and other Additional Files.
2e1d04bc
JH
1320
1321It's well known that software developers usually fully document the
1322software they write. If, however, the world is in urgent need of
1323your software and there is not enough time to write the full
1324documentation please at least provide a README file containing:
1325
1326=over 10
1327
1328=item *
ac634a9a 1329
2e1d04bc
JH
1330A description of the module/package/extension etc.
1331
1332=item *
ac634a9a 1333
2e1d04bc
JH
1334A copyright notice - see below.
1335
1336=item *
ac634a9a 1337
2e1d04bc
JH
1338Prerequisites - what else you may need to have.
1339
1340=item *
ac634a9a 1341
2e1d04bc
JH
1342How to build it - possible changes to Makefile.PL etc.
1343
1344=item *
ac634a9a 1345
2e1d04bc
JH
1346How to install it.
1347
1348=item *
ac634a9a 1349
2e1d04bc
JH
1350Recent changes in this release, especially incompatibilities
1351
1352=item *
ac634a9a 1353
2e1d04bc
JH
1354Changes / enhancements you plan to make in the future.
1355
1356=back
1357
1358If the README file seems to be getting too large you may wish to
1359split out some of the sections into separate files: INSTALL,
1360Copying, ToDo etc.
1361
1362=over 4
1363
c165c82a 1364=item *
2e1d04bc 1365
c165c82a 1366Adding a Copyright Notice.
ac634a9a 1367
2e1d04bc
JH
1368How you choose to license your work is a personal decision.
1369The general mechanism is to assert your Copyright and then make
1370a declaration of how others may copy/use/modify your work.
1371
2a551100
JH
1372Perl, for example, is supplied with two types of licence: The GNU GPL
1373and The Artistic Licence (see the files README, Copying, and Artistic,
1374or L<perlgpl> and L<perlartistic>). Larry has good reasons for NOT
1375just using the GNU GPL.
2e1d04bc
JH
1376
1377My personal recommendation, out of respect for Larry, Perl, and the
1378Perl community at large is to state something simply like:
1379
1380 Copyright (c) 1995 Your Name. All rights reserved.
1381 This program is free software; you can redistribute it and/or
1382 modify it under the same terms as Perl itself.
1383
1384This statement should at least appear in the README file. You may
1385also wish to include it in a Copying file and your source files.
1386Remember to include the other words in addition to the Copyright.
1387
ac634a9a
JH
1388=item *
1389
1390Give the module a version/issue/release number.
2e1d04bc
JH
1391
1392To be fully compatible with the Exporter and MakeMaker modules you
1393should store your module's version number in a non-my package
f39335f9 1394variable called $VERSION. This should be a positive floating point
2e1d04bc
JH
1395number with at least two digits after the decimal (i.e., hundredths,
1396e.g, C<$VERSION = "0.01">). Don't use a "1.3.2" style version.
1397See L<Exporter> for details.
1398
1399It may be handy to add a function or method to retrieve the number.
1400Use the number in announcements and archive file names when
1401releasing the module (ModuleName-1.02.tar.Z).
1402See perldoc ExtUtils::MakeMaker.pm for details.
1403
ac634a9a
JH
1404=item *
1405
1406How to release and distribute a module.
2e1d04bc 1407
32356571
DC
1408If possible, register the module with CPAN. Follow the instructions
1409and links on:
2e1d04bc 1410
4e860d0a 1411 http://www.cpan.org/modules/04pause.html
2e1d04bc 1412
32356571 1413and upload to:
2e1d04bc 1414
e59066d8 1415 http://pause.perl.org/
2e1d04bc 1416
32356571
DC
1417and notify <modules@perl.org>. This will allow anyone to install
1418your module using the C<cpan> tool distributed with Perl.
2e1d04bc
JH
1419
1420By using the WWW interface you can ask the Upload Server to mirror
1421your modules from your ftp or WWW site into your own directory on
1422CPAN!
1423
ac634a9a
JH
1424=item *
1425
1426Take care when changing a released module.
2e1d04bc
JH
1427
1428Always strive to remain compatible with previous released versions.
1429Otherwise try to add a mechanism to revert to the
1430old behavior if people rely on it. Document incompatible changes.
1431
1432=back
1433
abf06cc1
MS
1434=back
1435
2e1d04bc
JH
1436=head2 Guidelines for Converting Perl 4 Library Scripts into Modules
1437
1438=over 4
1439
ac634a9a
JH
1440=item *
1441
1442There is no requirement to convert anything.
2e1d04bc
JH
1443
1444If it ain't broke, don't fix it! Perl 4 library scripts should
1445continue to work with no problems. You may need to make some minor
1446changes (like escaping non-array @'s in double quoted strings) but
1447there is no need to convert a .pl file into a Module for just that.
1448
ac634a9a
JH
1449=item *
1450
1451Consider the implications.
2e1d04bc
JH
1452
1453All Perl applications that make use of the script will need to
1454be changed (slightly) if the script is converted into a module. Is
1455it worth it unless you plan to make other changes at the same time?
1456
ac634a9a
JH
1457=item *
1458
1459Make the most of the opportunity.
2e1d04bc
JH
1460
1461If you are going to convert the script to a module you can use the
1462opportunity to redesign the interface. The guidelines for module
1463creation above include many of the issues you should consider.
1464
ac634a9a
JH
1465=item *
1466
1467The pl2pm utility will get you started.
2e1d04bc
JH
1468
1469This utility will read *.pl files (given as parameters) and write
1470corresponding *.pm files. The pl2pm utilities does the following:
1471
1472=over 10
1473
1474=item *
ac634a9a 1475
2e1d04bc
JH
1476Adds the standard Module prologue lines
1477
1478=item *
ac634a9a 1479
2e1d04bc
JH
1480Converts package specifiers from ' to ::
1481
1482=item *
ac634a9a 1483
2e1d04bc
JH
1484Converts die(...) to croak(...)
1485
1486=item *
ac634a9a 1487
2e1d04bc
JH
1488Several other minor changes
1489
1490=back
1491
1492Being a mechanical process pl2pm is not bullet proof. The converted
1493code will need careful checking, especially any package statements.
1494Don't delete the original .pl file till the new .pm one works!
1495
1496=back
1497
1498=head2 Guidelines for Reusing Application Code
1499
1500=over 4
1501
ac634a9a
JH
1502=item *
1503
1504Complete applications rarely belong in the Perl Module Library.
1505
1506=item *
2e1d04bc 1507
ac634a9a 1508Many applications contain some Perl code that could be reused.
2e1d04bc
JH
1509
1510Help save the world! Share your code in a form that makes it easy
1511to reuse.
1512
ac634a9a
JH
1513=item *
1514
1515Break-out the reusable code into one or more separate module files.
1516
1517=item *
1518
1519Take the opportunity to reconsider and redesign the interfaces.
2e1d04bc 1520
ac634a9a 1521=item *
2e1d04bc 1522
ac634a9a 1523In some cases the 'application' can then be reduced to a small
2e1d04bc
JH
1524
1525fragment of code built on top of the reusable modules. In these cases
1526the application could invoked as:
1527
1528 % perl -e 'use Module::Name; method(@ARGV)' ...
1529or
1530 % perl -mModule::Name ... (in perl5.002 or higher)
1531
1532=back
1533
1534=head1 NOTE
1535
1536Perl does not enforce private and public parts of its modules as you may
1537have been used to in other languages like C++, Ada, or Modula-17. Perl
1538doesn't have an infatuation with enforced privacy. It would prefer
1539that you stayed out of its living room because you weren't invited, not
1540because it has a shotgun.
1541
1542The module and its user have a contract, part of which is common law,
1543and part of which is "written". Part of the common law contract is
1544that a module doesn't pollute any namespace it wasn't asked to. The
1545written contract for the module (A.K.A. documentation) may make other
1546provisions. But then you know when you C<use RedefineTheWorld> that
1547you're redefining the world and willing to take the consequences.
d72ea276
NC
1548
1549=cut
2e1d04bc 1550
f556af6c 1551read_only_bottom_close_and_rename($out);