Commit | Line | Data |
2e1d04bc |
1 | #!../miniperl |
2 | |
1fa7ca25 |
3 | $ENV{LC_ALL} = 'C'; |
4 | |
2e1d04bc |
5 | open (OUT, ">perlmodlib.tmp") or die $!; |
1fa7ca25 |
6 | my (@pragma, @mod, @MANIFEST); |
2e1d04bc |
7 | open (MANIFEST, "../MANIFEST") or die $!; |
8 | |
9 | while (<MANIFEST>) { |
10 | my $filename; |
11 | next unless s|^lib/|| or m|^ext/|; |
1fa7ca25 |
12 | ($filename) = m|^(\S+)|; |
2e1d04bc |
13 | $filename =~ s|^[^/]+/|| if $filename =~ s|^ext/||; |
1fa7ca25 |
14 | next unless $filename =~ m!\.p(m|od)$!; |
2e1d04bc |
15 | next unless open (MOD, "../lib/$filename"); |
4e860d0a |
16 | |
1fa7ca25 |
17 | |
2e1d04bc |
18 | my ($name, $thing); |
19 | my $foundit=0; |
4e860d0a |
20 | { |
21 | local $/=""; |
22 | while (<MOD>) { |
23 | next unless /^=head1 NAME/; |
24 | $foundit++; |
25 | last; |
26 | } |
2e1d04bc |
27 | } |
4e860d0a |
28 | unless ($foundit) { |
1fa7ca25 |
29 | warn "$filename missing =head1 NAME (okay if there is respective .pod)\n"; |
4e860d0a |
30 | next; |
2e1d04bc |
31 | } |
2e1d04bc |
32 | my $title = <MOD>; |
33 | chomp($title); |
34 | close MOD; |
35 | |
36 | my $perlname = $filename; |
4e860d0a |
37 | $perlname =~ s!\.p(m|od)$!!; |
38 | $perlname =~ s!/!::!g; |
39 | |
40 | ($name, $thing) = split / --? /, $title, 2; |
41 | |
42 | unless ($name and $thing) { |
43 | warn "$filename missing name\n" unless $name; |
44 | warn "$filename missing thing\n" unless $thing; |
45 | next; |
46 | } |
2e1d04bc |
47 | |
1fa7ca25 |
48 | |
4e860d0a |
49 | $thing =~ s/^perl pragma to //i; |
50 | $thing = ucfirst($thing); |
2e1d04bc |
51 | $title = "=item $perlname\n\n$thing\n\n"; |
52 | |
1fa7ca25 |
53 | if ($filename =~ /[A-Z]/) { |
2e1d04bc |
54 | push @mod, $title; |
55 | } else { |
56 | push @pragma, $title; |
57 | } |
58 | } |
59 | |
60 | print OUT <<'EOF'; |
843dbe26 |
61 | # Generated by perlmodlib.PL DO NOT EDIT! |
62 | |
2e1d04bc |
63 | =head1 NAME |
64 | |
65 | perlmodlib - constructing new Perl modules and finding existing ones |
66 | |
67 | =head1 DESCRIPTION |
68 | |
69 | =head1 THE PERL MODULE LIBRARY |
70 | |
71 | Many modules are included the Perl distribution. These are described |
72 | below, and all end in F<.pm>. You may discover compiled library |
73 | file (usually ending in F<.so>) or small pieces of modules to be |
74 | autoloaded (ending in F<.al>); these were automatically generated |
75 | by the installation process. You may also discover files in the |
76 | library directory that end in either F<.pl> or F<.ph>. These are |
77 | old libraries supplied so that old programs that use them still |
78 | run. The F<.pl> files will all eventually be converted into standard |
79 | modules, and the F<.ph> files made by B<h2ph> will probably end up |
80 | as extension modules made by B<h2xs>. (Some F<.ph> values may |
81 | already be available through the POSIX, Errno, or Fcntl modules.) |
82 | The B<pl2pm> file in the distribution may help in your conversion, |
83 | but it's just a mechanical process and therefore far from bulletproof. |
84 | |
85 | =head2 Pragmatic Modules |
86 | |
87 | They work somewhat like compiler directives (pragmata) in that they |
88 | tend to affect the compilation of your program, and thus will usually |
89 | work well only when used within a C<use>, or C<no>. Most of these |
90 | are lexically scoped, so an inner BLOCK may countermand them |
91 | by saying: |
92 | |
93 | no integer; |
94 | no strict 'refs'; |
95 | no warnings; |
96 | |
97 | which lasts until the end of that BLOCK. |
98 | |
99 | Some pragmas are lexically scoped--typically those that affect the |
100 | C<$^H> hints variable. Others affect the current package instead, |
101 | like C<use vars> and C<use subs>, which allow you to predeclare a |
102 | variables or subroutines within a particular I<file> rather than |
103 | just a block. Such declarations are effective for the entire file |
104 | for which they were declared. You cannot rescind them with C<no |
105 | vars> or C<no subs>. |
106 | |
107 | The following pragmas are defined (and have their own documentation). |
108 | |
109 | =over 12 |
110 | |
111 | EOF |
112 | |
113 | print OUT $_ for (sort @pragma); |
114 | |
115 | print OUT <<EOF; |
116 | =back |
117 | |
118 | =head2 Standard Modules |
119 | |
120 | Standard, bundled modules are all expected to behave in a well-defined |
121 | manner with respect to namespace pollution because they use the |
122 | Exporter module. See their own documentation for details. |
123 | |
124 | =over 12 |
125 | |
126 | EOF |
127 | |
128 | print OUT $_ for (sort @mod); |
129 | |
130 | print OUT <<'EOF'; |
131 | =back |
132 | |
133 | To find out I<all> modules installed on your system, including |
134 | those without documentation or outside the standard release, |
309a139e |
135 | just do this: |
2e1d04bc |
136 | |
137 | % find `perl -e 'print "@INC"'` -name '*.pm' -print |
138 | |
139 | They should all have their own documentation installed and accessible |
140 | via your system man(1) command. If you do not have a B<find> |
141 | program, you can use the Perl B<find2perl> program instead, which |
142 | generates Perl code as output you can run through perl. If you |
143 | have a B<man> program but it doesn't find your modules, you'll have |
144 | to fix your manpath. See L<perl> for details. If you have no |
145 | system B<man> command, you might try the B<perldoc> program. |
146 | |
147 | =head2 Extension Modules |
148 | |
149 | Extension modules are written in C (or a mix of Perl and C). They |
150 | are usually dynamically loaded into Perl if and when you need them, |
151 | but may also be be linked in statically. Supported extension modules |
152 | include Socket, Fcntl, and POSIX. |
153 | |
154 | Many popular C extension modules do not come bundled (at least, not |
155 | completely) due to their sizes, volatility, or simply lack of time |
156 | for adequate testing and configuration across the multitude of |
157 | platforms on which Perl was beta-tested. You are encouraged to |
158 | look for them on CPAN (described below), or using web search engines |
159 | like Alta Vista or Deja News. |
160 | |
161 | =head1 CPAN |
162 | |
163 | CPAN stands for Comprehensive Perl Archive Network; it's a globally |
164 | replicated trove of Perl materials, including documentation, style |
165 | guides, tricks and traps, alternate ports to non-Unix systems and |
166 | occasional binary distributions for these. Search engines for |
167 | CPAN can be found at http://cpan.perl.com/ and at |
168 | http://theory.uwinnipeg.ca/mod_perl/cpan-search.pl . |
169 | |
170 | Most importantly, CPAN includes around a thousand unbundled modules, |
171 | some of which require a C compiler to build. Major categories of |
172 | modules are: |
173 | |
174 | =over |
175 | |
176 | =item * |
ac634a9a |
177 | |
2e1d04bc |
178 | Language Extensions and Documentation Tools |
179 | |
180 | =item * |
ac634a9a |
181 | |
2e1d04bc |
182 | Development Support |
183 | |
184 | =item * |
ac634a9a |
185 | |
2e1d04bc |
186 | Operating System Interfaces |
187 | |
188 | =item * |
ac634a9a |
189 | |
2e1d04bc |
190 | Networking, Device Control (modems) and InterProcess Communication |
191 | |
192 | =item * |
ac634a9a |
193 | |
2e1d04bc |
194 | Data Types and Data Type Utilities |
195 | |
196 | =item * |
ac634a9a |
197 | |
2e1d04bc |
198 | Database Interfaces |
199 | |
200 | =item * |
ac634a9a |
201 | |
2e1d04bc |
202 | User Interfaces |
203 | |
204 | =item * |
ac634a9a |
205 | |
2e1d04bc |
206 | Interfaces to / Emulations of Other Programming Languages |
207 | |
208 | =item * |
ac634a9a |
209 | |
2e1d04bc |
210 | File Names, File Systems and File Locking (see also File Handles) |
211 | |
212 | =item * |
ac634a9a |
213 | |
2e1d04bc |
214 | String Processing, Language Text Processing, Parsing, and Searching |
215 | |
216 | =item * |
ac634a9a |
217 | |
2e1d04bc |
218 | Option, Argument, Parameter, and Configuration File Processing |
219 | |
220 | =item * |
ac634a9a |
221 | |
2e1d04bc |
222 | Internationalization and Locale |
223 | |
224 | =item * |
ac634a9a |
225 | |
2e1d04bc |
226 | Authentication, Security, and Encryption |
227 | |
228 | =item * |
ac634a9a |
229 | |
2e1d04bc |
230 | World Wide Web, HTML, HTTP, CGI, MIME |
231 | |
232 | =item * |
ac634a9a |
233 | |
2e1d04bc |
234 | Server and Daemon Utilities |
235 | |
236 | =item * |
ac634a9a |
237 | |
2e1d04bc |
238 | Archiving and Compression |
239 | |
240 | =item * |
ac634a9a |
241 | |
2e1d04bc |
242 | Images, Pixmap and Bitmap Manipulation, Drawing, and Graphing |
243 | |
244 | =item * |
ac634a9a |
245 | |
2e1d04bc |
246 | Mail and Usenet News |
247 | |
248 | =item * |
ac634a9a |
249 | |
2e1d04bc |
250 | Control Flow Utilities (callbacks and exceptions etc) |
251 | |
252 | =item * |
ac634a9a |
253 | |
2e1d04bc |
254 | File Handle and Input/Output Stream Utilities |
255 | |
256 | =item * |
ac634a9a |
257 | |
2e1d04bc |
258 | Miscellaneous Modules |
259 | |
260 | =back |
261 | |
262 | Registered CPAN sites as of this writing include the following. |
263 | You should try to choose one close to you: |
264 | |
4e860d0a |
265 | =head2 Africa |
266 | |
267 | =over 4 |
268 | |
269 | =item * |
270 | |
271 | South Africa |
272 | |
273 | ftp://ftp.is.co.za/programming/perl/CPAN/ |
274 | ftp://ftp.saix.net/pub/CPAN/ |
275 | ftp://ftpza.co.za/pub/mirrors/cpan/ |
276 | ftp://ftp.sun.ac.za/CPAN/ |
277 | |
278 | =back |
279 | |
280 | =head2 Asia |
281 | |
282 | =over 4 |
283 | |
284 | =item * |
285 | |
286 | China |
287 | |
288 | ftp://freesoft.cei.gov.cn/pub/languages/perl/CPAN/ |
289 | http://www2.linuxforum.net/mirror/CPAN/ |
290 | http://cpan.shellhung.org/ |
291 | ftp://ftp.shellhung.org/pub/CPAN |
292 | |
293 | =item * |
294 | |
295 | Hong Kong |
296 | |
297 | http://CPAN.pacific.net.hk/ |
298 | ftp://ftp.pacific.net.hk/pub/mirror/CPAN/ |
299 | |
300 | =item * |
301 | |
302 | Indonesia |
303 | |
304 | http://piksi.itb.ac.id/CPAN/ |
305 | ftp://mirrors.piksi.itb.ac.id/CPAN/ |
306 | http://CPAN.mweb.co.id/ |
307 | ftp://ftp.mweb.co.id/pub/languages/perl/CPAN/ |
308 | |
309 | =item * |
310 | |
311 | Israel |
312 | |
313 | http://www.iglu.org.il:/pub/CPAN/ |
314 | ftp://ftp.iglu.org.il/pub/CPAN/ |
315 | http://bioinfo.weizmann.ac.il/pub/software/perl/CPAN/ |
316 | ftp://bioinfo.weizmann.ac.il/pub/software/perl/CPAN/ |
317 | |
318 | =item * |
319 | |
320 | Japan |
321 | |
322 | ftp://ftp.u-aizu.ac.jp/pub/lang/perl/CPAN/ |
323 | ftp://ftp.kddlabs.co.jp/CPAN/ |
324 | http://mirror.nucba.ac.jp/mirror/Perl/ |
325 | ftp://mirror.nucba.ac.jp/mirror/Perl/ |
326 | ftp://ftp.meisei-u.ac.jp/pub/CPAN/ |
327 | ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/ |
328 | ftp://ftp.dti.ad.jp/pub/lang/CPAN/ |
329 | ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/ |
330 | |
331 | =item * |
332 | |
333 | Saudi Arabia |
334 | |
335 | ftp://ftp.isu.net.sa/pub/CPAN/ |
336 | |
337 | =item * |
338 | |
339 | Singapore |
340 | |
341 | http://cpan.hjc.edu.sg |
342 | http://ftp.nus.edu.sg/unix/perl/CPAN/ |
343 | ftp://ftp.nus.edu.sg/pub/unix/perl/CPAN/ |
344 | |
345 | =item * |
346 | |
347 | South Korea |
348 | |
349 | http://CPAN.bora.net/ |
350 | ftp://ftp.bora.net/pub/CPAN/ |
351 | http://ftp.kornet.net/CPAN/ |
352 | ftp://ftp.kornet.net/pub/CPAN/ |
353 | ftp://ftp.nuri.net/pub/CPAN/ |
354 | |
355 | =item * |
356 | |
357 | Taiwan |
358 | |
359 | ftp://coda.nctu.edu.tw/UNIX/perl/CPAN |
360 | ftp://ftp.ee.ncku.edu.tw/pub/perl/CPAN/ |
361 | ftp://ftp1.sinica.edu.tw/pub1/perl/CPAN/ |
362 | |
363 | =item * |
364 | |
365 | Thailand |
366 | |
367 | http://download.nectec.or.th/CPAN/ |
368 | ftp://ftp.nectec.or.th/pub/languages/CPAN/ |
369 | ftp://ftp.cs.riubon.ac.th/pub/mirrors/CPAN/ |
370 | |
371 | =back |
372 | |
373 | =head2 Central America |
374 | |
375 | =over 4 |
376 | |
377 | =item * |
378 | |
379 | Costa Rica |
380 | |
381 | ftp://ftp.linux.co.cr/mirrors/CPAN/ |
382 | http://ftp.ucr.ac.cr/Unix/CPAN/ |
383 | ftp://ftp.ucr.ac.cr/pub/Unix/CPAN/ |
384 | |
385 | =back |
386 | |
387 | =head2 Europe |
388 | |
389 | =over 4 |
390 | |
391 | =item * |
392 | |
393 | Austria |
394 | |
395 | ftp://ftp.tuwien.ac.at/pub/languages/perl/CPAN/ |
396 | |
397 | =item * |
398 | |
399 | Belgium |
400 | |
401 | http://ftp.easynet.be/CPAN/ |
402 | ftp://ftp.easynet.be/CPAN/ |
403 | ftp://ftp.kulnet.kuleuven.ac.be/pub/mirror/CPAN/ |
404 | |
405 | =item * |
406 | |
407 | Bulgaria |
408 | |
409 | ftp://ftp.ntrl.net/pub/mirrors/CPAN/ |
410 | |
411 | =item * |
412 | |
413 | Croatia |
414 | |
415 | ftp://ftp.linux.hr/pub/CPAN/ |
416 | |
417 | =item * |
418 | |
419 | Czech Republic |
420 | |
421 | http://www.fi.muni.cz/pub/perl/ |
422 | ftp://ftp.fi.muni.cz/pub/perl/ |
423 | ftp://sunsite.mff.cuni.cz/MIRRORS/ftp.funet.fi/pub/languages/perl/CPAN/ |
424 | |
425 | =item * |
426 | |
427 | Denmark |
428 | |
429 | ftp://sunsite.auc.dk/pub/languages/perl/CPAN/ |
430 | http://www.cpan.dk/CPAN/ |
431 | ftp://www.cpan.dk/ftp.cpan.org/CPAN/ |
432 | |
433 | =item * |
434 | |
435 | England |
436 | |
437 | http://www.mirror.ac.uk/sites/ftp.funet.fi/pub/languages/perl/CPAN |
438 | ftp://ftp.mirror.ac.uk/sites/ftp.funet.fi/pub/languages/perl/CPAN/ |
439 | ftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/ |
440 | ftp://ftp.flirble.org/pub/languages/perl/CPAN/ |
441 | ftp://ftp.plig.org/pub/CPAN/ |
442 | ftp://sunsite.doc.ic.ac.uk/packages/CPAN/ |
443 | http://mirror.uklinux.net/CPAN/ |
444 | ftp://mirror.uklinux.net/pub/CPAN/ |
445 | ftp://usit.shef.ac.uk/pub/packages/CPAN/ |
446 | |
447 | =item * |
448 | |
449 | Estonia |
450 | |
451 | ftp://ftp.ut.ee/pub/languages/perl/CPAN/ |
452 | |
453 | =item * |
454 | |
455 | Finland |
456 | |
457 | ftp://ftp.funet.fi/pub/languages/perl/CPAN/ |
458 | |
459 | =item * |
460 | |
461 | France |
462 | |
463 | ftp://cpan.ftp.worldonline.fr/pub/CPAN/ |
464 | ftp://ftp.club-internet.fr/pub/perl/CPAN/ |
465 | ftp://ftp.lip6.fr/pub/perl/CPAN/ |
466 | ftp://ftp.oleane.net/pub/mirrors/CPAN/ |
467 | ftp://ftp.pasteur.fr/pub/computing/CPAN/ |
468 | ftp://cpan.cict.fr/pub/CPAN/ |
469 | ftp://ftp.uvsq.fr/pub/perl/CPAN/ |
470 | |
471 | =item * |
472 | |
473 | Germany |
474 | |
475 | ftp://ftp.rz.ruhr-uni-bochum.de/pub/CPAN/ |
476 | ftp://ftp.freenet.de/pub/ftp.cpan.org/pub/CPAN/ |
477 | ftp://ftp.uni-erlangen.de/pub/source/CPAN/ |
478 | ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/CPAN |
479 | ftp://ftp.gigabell.net/pub/CPAN/ |
480 | http://ftp.gwdg.de/pub/languages/perl/CPAN/ |
481 | ftp://ftp.gwdg.de/pub/languages/perl/CPAN/ |
482 | ftp://ftp.uni-hamburg.de/pub/soft/lang/perl/CPAN/ |
483 | ftp://ftp.leo.org/pub/comp/general/programming/languages/script/perl/CPAN/ |
484 | ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/ |
485 | ftp://ftp.gmd.de/mirrors/CPAN/ |
486 | |
487 | =item * |
488 | |
489 | Greece |
490 | |
491 | ftp://ftp.forthnet.gr/pub/languages/perl/CPAN |
492 | ftp://ftp.ntua.gr/pub/lang/perl/ |
493 | |
494 | =item * |
495 | |
496 | Hungary |
497 | |
498 | http://cpan.artifact.hu/ |
499 | ftp://cpan.artifact.hu/CPAN/ |
500 | ftp://ftp.kfki.hu/pub/packages/perl/CPAN/ |
501 | |
502 | =item * |
503 | |
504 | Iceland |
505 | |
506 | http://cpan.gm.is/ |
507 | ftp://ftp.gm.is/pub/CPAN/ |
508 | |
509 | =item * |
510 | |
511 | Ireland |
512 | |
513 | http://cpan.indigo.ie/ |
514 | ftp://cpan.indigo.ie/pub/CPAN/ |
515 | http://sunsite.compapp.dcu.ie/pub/perl/ |
516 | ftp://sunsite.compapp.dcu.ie/pub/perl/ |
517 | |
518 | =item * |
519 | |
520 | Italy |
521 | |
522 | http://cpan.nettuno.it/ |
523 | http://gusp.dyndns.org/CPAN/ |
524 | ftp://gusp.dyndns.org/pub/CPAN |
525 | http://softcity.iol.it/cpan |
526 | ftp://softcity.iol.it/pub/cpan |
527 | ftp://ftp.unina.it/pub/Other/CPAN/ |
528 | ftp://ftp.unipi.it/pub/mirror/perl/CPAN/ |
529 | ftp://cis.uniRoma2.it/CPAN/ |
530 | ftp://ftp.edisontel.it/pub/CPAN_Mirror/ |
531 | ftp://ftp.flashnet.it/pub/CPAN/ |
532 | |
533 | =item * |
534 | |
535 | Latvia |
536 | |
537 | http://kvin.lv/pub/CPAN/ |
538 | |
539 | =item * |
540 | |
541 | Netherlands |
542 | |
543 | ftp://download.xs4all.nl/pub/mirror/CPAN/ |
544 | ftp://ftp.nl.uu.net/pub/CPAN/ |
545 | ftp://ftp.nluug.nl/pub/languages/perl/CPAN/ |
546 | ftp://ftp.cpan.nl/pub/CPAN/ |
547 | http://www.cs.uu.nl/mirror/CPAN/ |
548 | ftp://ftp.cs.uu.nl/mirror/CPAN/ |
549 | |
550 | =item * |
551 | |
552 | Norway |
553 | |
554 | ftp://sunsite.uio.no/pub/languages/perl/CPAN/ |
555 | ftp://ftp.uit.no/pub/languages/perl/cpan/ |
556 | |
557 | =item * |
558 | |
559 | Poland |
560 | |
561 | ftp://ftp.pk.edu.pl/pub/lang/perl/CPAN/ |
562 | ftp://ftp.mega.net.pl/pub/mirrors/ftp.perl.com/ |
563 | ftp://ftp.man.torun.pl/pub/doc/CPAN/ |
564 | ftp://sunsite.icm.edu.pl/pub/CPAN/ |
565 | |
566 | =item * |
567 | |
568 | Portugal |
569 | |
570 | ftp://ftp.ua.pt/pub/CPAN/ |
571 | ftp://perl.di.uminho.pt/pub/CPAN/ |
572 | ftp://ftp.ist.utl.pt/pub/CPAN/ |
573 | ftp://ftp.netc.pt/pub/CPAN/ |
574 | |
575 | =item * |
576 | |
577 | Romania |
578 | |
579 | ftp://archive.logicnet.ro/mirrors/ftp.cpan.org/CPAN/ |
580 | ftp://ftp.kappa.ro/pub/mirrors/ftp.perl.org/pub/CPAN/ |
581 | ftp://ftp.dntis.ro/pub/cpan/ |
582 | ftp://ftp.opsynet.com/cpan/ |
583 | ftp://ftp.dnttm.ro/pub/CPAN/ |
584 | ftp://ftp.timisoara.roedu.net/mirrors/CPAN/ |
585 | |
586 | =item * |
587 | |
588 | Russia |
589 | |
590 | ftp://ftp.chg.ru/pub/lang/perl/CPAN/ |
591 | http://cpan.rinet.ru/ |
592 | ftp://cpan.rinet.ru/pub/mirror/CPAN/ |
593 | ftp://ftp.aha.ru/pub/CPAN/ |
594 | ftp://ftp.sai.msu.su/pub/lang/perl/CPAN/ |
595 | |
596 | =item * |
597 | |
598 | Slovakia |
599 | |
600 | ftp://ftp.entry.sk/pub/languages/perl/CPAN/ |
601 | |
602 | =item * |
603 | |
604 | Slovenia |
605 | |
606 | ftp://ftp.arnes.si/software/perl/CPAN/ |
607 | |
608 | =item * |
609 | |
610 | Spain |
611 | |
612 | ftp://ftp.rediris.es/mirror/CPAN/ |
613 | ftp://ftp.etse.urv.es/pub/perl/ |
614 | |
615 | =item * |
616 | |
617 | Sweden |
618 | |
619 | http://ftp.du.se/CPAN/ |
620 | ftp://ftp.du.se/pub/CPAN/ |
621 | ftp://ftp.sunet.se/pub/lang/perl/CPAN/ |
622 | |
623 | =item * |
624 | |
625 | Switzerland |
626 | |
627 | ftp://ftp.danyk.ch/CPAN/ |
628 | ftp://sunsite.cnlab-switch.ch/mirror/CPAN/ |
629 | |
630 | =item * |
631 | |
632 | Turkey |
633 | |
634 | ftp://sunsite.bilkent.edu.tr/pub/languages/CPAN/ |
635 | |
636 | =back |
637 | |
638 | =head2 North America |
639 | |
640 | =over 4 |
641 | |
642 | =item * |
643 | |
644 | Canada |
645 | |
646 | =over 8 |
647 | |
648 | =item * |
649 | |
650 | Alberta |
651 | |
652 | http://sunsite.ualberta.ca/pub/Mirror/CPAN/ |
653 | ftp://sunsite.ualberta.ca/pub/Mirror/CPAN/ |
654 | |
655 | =item * |
656 | |
657 | Manitoba |
658 | |
659 | http://theoryx5.uwinnipeg.ca/pub/CPAN/ |
660 | ftp://theoryx5.uwinnipeg.ca/pub/CPAN/ |
661 | |
662 | =item * |
663 | |
664 | Nova Scotia |
665 | |
666 | ftp://cpan.chebucto.ns.ca/pub/CPAN/ |
667 | |
668 | =item * |
669 | |
670 | Ontario |
671 | |
672 | ftp://ftp.crc.ca/pub/packages/lang/perl/CPAN/ |
673 | |
674 | =item * |
675 | |
676 | Mexico |
677 | |
678 | http://www.msg.com.mx/CPAN/ |
679 | ftp://ftp.msg.com.mx/pub/CPAN/ |
680 | |
681 | =back |
682 | |
683 | =item * |
684 | |
685 | United States |
686 | |
687 | =over 8 |
688 | |
689 | =item * |
690 | |
691 | Alabama |
692 | |
693 | http://mirror.hiwaay.net/CPAN/ |
694 | ftp://mirror.hiwaay.net/CPAN/ |
695 | |
696 | =item * |
697 | |
698 | California |
699 | |
700 | http://www.cpan.org/ |
701 | ftp://ftp.cpan.org/CPAN/ |
702 | ftp://cpan.nas.nasa.gov/pub/perl/CPAN/ |
703 | ftp://ftp.digital.com/pub/plan/perl/CPAN/ |
704 | http://www.kernel.org/pub/mirrors/cpan/ |
705 | ftp://ftp.kernel.org/pub/mirrors/cpan/ |
706 | http://www.perl.com/CPAN/ |
707 | http://download.sourceforge.net/mirrors/CPAN/ |
708 | |
709 | =item * |
710 | |
711 | Colorado |
712 | |
713 | ftp://ftp.cs.colorado.edu/pub/perl/CPAN/ |
714 | |
715 | =item * |
716 | |
717 | Florida |
718 | |
719 | ftp://ftp.cise.ufl.edu/pub/perl/CPAN/ |
720 | |
721 | =item * |
722 | |
723 | Georgia |
724 | |
725 | ftp://ftp.twoguys.org/CPAN/ |
726 | |
727 | =item * |
728 | |
729 | Illinois |
730 | |
731 | http://www.neurogames.com/mirrors/CPAN |
732 | http://uiarchive.uiuc.edu/mirrors/ftp/ftp.cpan.org/pub/CPAN/ |
733 | ftp://uiarchive.uiuc.edu/mirrors/ftp/ftp.cpan.org/pub/CPAN/ |
734 | |
735 | =item * |
736 | |
737 | Indiana |
738 | |
739 | ftp://ftp.uwsg.indiana.edu/pub/perl/CPAN/ |
740 | http://cpan.nitco.com/ |
741 | ftp://cpan.nitco.com/pub/CPAN/ |
742 | ftp://cpan.in-span.net/ |
743 | http://csociety-ftp.ecn.purdue.edu/pub/CPAN |
744 | ftp://csociety-ftp.ecn.purdue.edu/pub/CPAN |
745 | |
746 | =item * |
747 | |
748 | Kentucky |
749 | |
750 | http://cpan.uky.edu/ |
751 | ftp://cpan.uky.edu/pub/CPAN/ |
752 | |
753 | =item * |
754 | |
755 | Massachusetts |
756 | |
757 | ftp://ftp.ccs.neu.edu/net/mirrors/ftp.funet.fi/pub/languages/perl/CPAN/ |
758 | ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN/ |
759 | |
760 | =item * |
761 | |
762 | New Jersey |
763 | |
764 | ftp://ftp.cpanel.net/pub/CPAN/ |
765 | |
766 | =item * |
767 | |
768 | New York |
769 | |
770 | ftp://ftp.freesoftware.com/pub/perl/CPAN/ |
771 | http://www.deao.net/mirrors/CPAN/ |
772 | ftp://ftp.deao.net/pub/CPAN/ |
773 | ftp://ftp.stealth.net/pub/mirrors/ftp.cpan.org/pub/CPAN/ |
774 | http://mirror.nyc.anidea.com/CPAN/ |
775 | ftp://mirror.nyc.anidea.com/pub/CPAN/ |
776 | http://www.rge.com/pub/languages/perl/ |
777 | ftp://ftp.rge.com/pub/languages/perl/ |
778 | ftp://mirrors.cloud9.net/pub/mirrors/CPAN/ |
779 | |
780 | =item * |
781 | |
782 | North Carolina |
783 | |
784 | ftp://ftp.duke.edu/pub/perl/ |
785 | |
786 | =item * |
787 | |
788 | Ohio |
789 | |
790 | ftp://ftp.loaded.net/pub/CPAN/ |
791 | |
792 | =item * |
793 | |
794 | Oklahoma |
795 | |
796 | ftp://ftp.ou.edu/mirrors/CPAN/ |
797 | |
798 | =item * |
799 | |
800 | Oregon |
801 | |
802 | ftp://ftp.orst.edu/pub/packages/CPAN/ |
803 | |
804 | =item * |
805 | |
806 | Pennsylvania |
807 | |
808 | http://ftp.epix.net/CPAN/ |
809 | ftp://ftp.epix.net/pub/languages/perl/ |
810 | ftp://carroll.cac.psu.edu/pub/CPAN/ |
811 | |
812 | =item * |
813 | |
814 | Tennessee |
815 | |
816 | ftp://ftp.sunsite.utk.edu/pub/CPAN/ |
817 | |
818 | =item * |
819 | |
820 | Texas |
821 | |
822 | http://ftp.sedl.org/pub/mirrors/CPAN/ |
823 | http://jhcloos.com/pub/mirror/CPAN/ |
824 | ftp://jhcloos.com/pub/mirror/CPAN/ |
825 | |
826 | =item * |
827 | |
828 | Utah |
829 | |
830 | ftp://mirror.xmission.com/CPAN/ |
831 | |
832 | =item * |
833 | |
834 | Virginia |
835 | |
836 | http://mirrors.rcn.net/pub/lang/CPAN/ |
837 | ftp://mirrors.rcn.net/pub/lang/CPAN/ |
838 | ftp://ruff.cs.jmu.edu/pub/CPAN/ |
839 | http://perl.Liquidation.com/CPAN/ |
840 | |
841 | =item * |
842 | |
843 | Washington |
844 | |
845 | http://cpan.llarian.net/ |
846 | ftp://cpan.llarian.net/pub/CPAN/ |
847 | ftp://ftp-mirror.internap.com/pub/CPAN/ |
848 | ftp://ftp.spu.edu/pub/CPAN/ |
849 | |
850 | =back |
851 | |
852 | =back |
853 | |
854 | =head2 Oceania |
855 | |
856 | =over 4 |
857 | |
858 | =item * |
859 | |
860 | Australia |
861 | |
862 | http://ftp.planetmirror.com/pub/CPAN/ |
863 | ftp://ftp.planetmirror.com/pub/CPAN/ |
864 | ftp://mirror.aarnet.edu.au/pub/perl/CPAN/ |
865 | ftp://cpan.topend.com.au/pub/CPAN/ |
866 | |
867 | =item * |
868 | |
869 | New Zealand |
870 | |
871 | ftp://ftp.auckland.ac.nz/pub/perl/CPAN/ |
872 | |
873 | =back |
874 | |
875 | =head2 South America |
876 | |
877 | =over 4 |
878 | |
879 | =item * |
880 | |
881 | Argentina |
882 | |
883 | ftp://mirrors.bannerlandia.com.ar/mirrors/CPAN/ |
884 | |
885 | =item * |
886 | |
887 | Brazil |
888 | |
889 | ftp://cpan.pop-mg.com.br/pub/CPAN/ |
890 | ftp://ftp.matrix.com.br/pub/perl/ |
891 | ftp://cpan.if.usp.br/pub/mirror/CPAN/ |
892 | |
893 | =item * |
894 | |
895 | Chile |
2e1d04bc |
896 | |
4e860d0a |
897 | ftp://ftp.psinet.cl/pub/programming/perl/CPAN/ |
898 | ftp://sunsite.dcc.uchile.cl/pub/lang/perl/ |
2e1d04bc |
899 | |
900 | =back |
901 | |
902 | For an up-to-date listing of CPAN sites, |
4e860d0a |
903 | see http://www.cpan.org/SITES or ftp://www.cpan.org/SITES . |
2e1d04bc |
904 | |
905 | =head1 Modules: Creation, Use, and Abuse |
906 | |
907 | (The following section is borrowed directly from Tim Bunce's modules |
908 | file, available at your nearest CPAN site.) |
909 | |
910 | Perl implements a class using a package, but the presence of a |
911 | package doesn't imply the presence of a class. A package is just a |
912 | namespace. A class is a package that provides subroutines that can be |
913 | used as methods. A method is just a subroutine that expects, as its |
914 | first argument, either the name of a package (for "static" methods), |
915 | or a reference to something (for "virtual" methods). |
916 | |
917 | A module is a file that (by convention) provides a class of the same |
918 | name (sans the .pm), plus an import method in that class that can be |
919 | called to fetch exported symbols. This module may implement some of |
920 | its methods by loading dynamic C or C++ objects, but that should be |
921 | totally transparent to the user of the module. Likewise, the module |
922 | might set up an AUTOLOAD function to slurp in subroutine definitions on |
923 | demand, but this is also transparent. Only the F<.pm> file is required to |
924 | exist. See L<perlsub>, L<perltoot>, and L<AutoLoader> for details about |
925 | the AUTOLOAD mechanism. |
926 | |
927 | =head2 Guidelines for Module Creation |
928 | |
929 | =over 4 |
930 | |
ac634a9a |
931 | =item * |
932 | |
933 | Do similar modules already exist in some form? |
2e1d04bc |
934 | |
935 | If so, please try to reuse the existing modules either in whole or |
936 | by inheriting useful features into a new class. If this is not |
937 | practical try to get together with the module authors to work on |
938 | extending or enhancing the functionality of the existing modules. |
939 | A perfect example is the plethora of packages in perl4 for dealing |
940 | with command line options. |
941 | |
942 | If you are writing a module to expand an already existing set of |
943 | modules, please coordinate with the author of the package. It |
944 | helps if you follow the same naming scheme and module interaction |
945 | scheme as the original author. |
946 | |
ac634a9a |
947 | =item * |
948 | |
949 | Try to design the new module to be easy to extend and reuse. |
2e1d04bc |
950 | |
951 | Try to C<use warnings;> (or C<use warnings qw(...);>). |
952 | Remember that you can add C<no warnings qw(...);> to individual blocks |
953 | of code that need less warnings. |
954 | |
955 | Use blessed references. Use the two argument form of bless to bless |
956 | into the class name given as the first parameter of the constructor, |
957 | e.g.,: |
958 | |
959 | sub new { |
960 | my $class = shift; |
961 | return bless {}, $class; |
962 | } |
963 | |
964 | or even this if you'd like it to be used as either a static |
965 | or a virtual method. |
966 | |
967 | sub new { |
968 | my $self = shift; |
969 | my $class = ref($self) || $self; |
970 | return bless {}, $class; |
971 | } |
972 | |
973 | Pass arrays as references so more parameters can be added later |
974 | (it's also faster). Convert functions into methods where |
975 | appropriate. Split large methods into smaller more flexible ones. |
976 | Inherit methods from other modules if appropriate. |
977 | |
978 | Avoid class name tests like: C<die "Invalid" unless ref $ref eq 'FOO'>. |
979 | Generally you can delete the C<eq 'FOO'> part with no harm at all. |
980 | Let the objects look after themselves! Generally, avoid hard-wired |
981 | class names as far as possible. |
982 | |
983 | Avoid C<< $r->Class::func() >> where using C<@ISA=qw(... Class ...)> and |
984 | C<< $r->func() >> would work (see L<perlbot> for more details). |
985 | |
986 | Use autosplit so little used or newly added functions won't be a |
987 | burden to programs that don't use them. Add test functions to |
988 | the module after __END__ either using AutoSplit or by saying: |
989 | |
990 | eval join('',<main::DATA>) || die $@ unless caller(); |
991 | |
992 | Does your module pass the 'empty subclass' test? If you say |
993 | C<@SUBCLASS::ISA = qw(YOURCLASS);> your applications should be able |
994 | to use SUBCLASS in exactly the same way as YOURCLASS. For example, |
995 | does your application still work if you change: C<$obj = new YOURCLASS;> |
996 | into: C<$obj = new SUBCLASS;> ? |
997 | |
998 | Avoid keeping any state information in your packages. It makes it |
999 | difficult for multiple other packages to use yours. Keep state |
1000 | information in objects. |
1001 | |
1002 | Always use B<-w>. |
1003 | |
1004 | Try to C<use strict;> (or C<use strict qw(...);>). |
1005 | Remember that you can add C<no strict qw(...);> to individual blocks |
1006 | of code that need less strictness. |
1007 | |
1008 | Always use B<-w>. |
1009 | |
1010 | Follow the guidelines in the perlstyle(1) manual. |
1011 | |
1012 | Always use B<-w>. |
1013 | |
ac634a9a |
1014 | =item * |
1015 | |
1016 | Some simple style guidelines |
2e1d04bc |
1017 | |
1018 | The perlstyle manual supplied with Perl has many helpful points. |
1019 | |
1020 | Coding style is a matter of personal taste. Many people evolve their |
1021 | style over several years as they learn what helps them write and |
1022 | maintain good code. Here's one set of assorted suggestions that |
1023 | seem to be widely used by experienced developers: |
1024 | |
1025 | Use underscores to separate words. It is generally easier to read |
1026 | $var_names_like_this than $VarNamesLikeThis, especially for |
1027 | non-native speakers of English. It's also a simple rule that works |
1028 | consistently with VAR_NAMES_LIKE_THIS. |
1029 | |
1030 | Package/Module names are an exception to this rule. Perl informally |
1031 | reserves lowercase module names for 'pragma' modules like integer |
1032 | and strict. Other modules normally begin with a capital letter and |
1033 | use mixed case with no underscores (need to be short and portable). |
1034 | |
1035 | You may find it helpful to use letter case to indicate the scope |
1036 | or nature of a variable. For example: |
1037 | |
1038 | $ALL_CAPS_HERE constants only (beware clashes with Perl vars) |
1039 | $Some_Caps_Here package-wide global/static |
1040 | $no_caps_here function scope my() or local() variables |
1041 | |
1042 | Function and method names seem to work best as all lowercase. |
1043 | e.g., C<< $obj->as_string() >>. |
1044 | |
1045 | You can use a leading underscore to indicate that a variable or |
1046 | function should not be used outside the package that defined it. |
1047 | |
ac634a9a |
1048 | =item * |
1049 | |
1050 | Select what to export. |
2e1d04bc |
1051 | |
1052 | Do NOT export method names! |
1053 | |
1054 | Do NOT export anything else by default without a good reason! |
1055 | |
1056 | Exports pollute the namespace of the module user. If you must |
1057 | export try to use @EXPORT_OK in preference to @EXPORT and avoid |
1058 | short or common names to reduce the risk of name clashes. |
1059 | |
1060 | Generally anything not exported is still accessible from outside the |
1061 | module using the ModuleName::item_name (or C<< $blessed_ref->method >>) |
1062 | syntax. By convention you can use a leading underscore on names to |
1063 | indicate informally that they are 'internal' and not for public use. |
1064 | |
1065 | (It is actually possible to get private functions by saying: |
1066 | C<my $subref = sub { ... }; &$subref;>. But there's no way to call that |
1067 | directly as a method, because a method must have a name in the symbol |
1068 | table.) |
1069 | |
1070 | As a general rule, if the module is trying to be object oriented |
1071 | then export nothing. If it's just a collection of functions then |
1072 | @EXPORT_OK anything but use @EXPORT with caution. |
1073 | |
ac634a9a |
1074 | =item * |
1075 | |
1076 | Select a name for the module. |
2e1d04bc |
1077 | |
1078 | This name should be as descriptive, accurate, and complete as |
1079 | possible. Avoid any risk of ambiguity. Always try to use two or |
1080 | more whole words. Generally the name should reflect what is special |
1081 | about what the module does rather than how it does it. Please use |
1082 | nested module names to group informally or categorize a module. |
1083 | There should be a very good reason for a module not to have a nested name. |
1084 | Module names should begin with a capital letter. |
1085 | |
1086 | Having 57 modules all called Sort will not make life easy for anyone |
1087 | (though having 23 called Sort::Quick is only marginally better :-). |
1088 | Imagine someone trying to install your module alongside many others. |
1089 | If in any doubt ask for suggestions in comp.lang.perl.misc. |
1090 | |
1091 | If you are developing a suite of related modules/classes it's good |
1092 | practice to use nested classes with a common prefix as this will |
1093 | avoid namespace clashes. For example: Xyz::Control, Xyz::View, |
1094 | Xyz::Model etc. Use the modules in this list as a naming guide. |
1095 | |
1096 | If adding a new module to a set, follow the original author's |
1097 | standards for naming modules and the interface to methods in |
1098 | those modules. |
1099 | |
4844a3be |
1100 | If developing modules for private internal or project specific use, |
1101 | that will never be released to the public, then you should ensure |
1102 | that their names will not clash with any future public module. You |
1103 | can do this either by using the reserved Local::* category or by |
1104 | using a category name that includes an underscore like Foo_Corp::*. |
1105 | |
2e1d04bc |
1106 | To be portable each component of a module name should be limited to |
1107 | 11 characters. If it might be used on MS-DOS then try to ensure each is |
1108 | unique in the first 8 characters. Nested modules make this easier. |
1109 | |
ac634a9a |
1110 | =item * |
1111 | |
1112 | Have you got it right? |
2e1d04bc |
1113 | |
1114 | How do you know that you've made the right decisions? Have you |
1115 | picked an interface design that will cause problems later? Have |
1116 | you picked the most appropriate name? Do you have any questions? |
1117 | |
1118 | The best way to know for sure, and pick up many helpful suggestions, |
1119 | is to ask someone who knows. Comp.lang.perl.misc is read by just about |
1120 | all the people who develop modules and it's the best place to ask. |
1121 | |
1122 | All you need to do is post a short summary of the module, its |
1123 | purpose and interfaces. A few lines on each of the main methods is |
1124 | probably enough. (If you post the whole module it might be ignored |
1125 | by busy people - generally the very people you want to read it!) |
1126 | |
1127 | Don't worry about posting if you can't say when the module will be |
1128 | ready - just say so in the message. It might be worth inviting |
1129 | others to help you, they may be able to complete it for you! |
1130 | |
ac634a9a |
1131 | =item * |
1132 | |
1133 | README and other Additional Files. |
2e1d04bc |
1134 | |
1135 | It's well known that software developers usually fully document the |
1136 | software they write. If, however, the world is in urgent need of |
1137 | your software and there is not enough time to write the full |
1138 | documentation please at least provide a README file containing: |
1139 | |
1140 | =over 10 |
1141 | |
1142 | =item * |
ac634a9a |
1143 | |
2e1d04bc |
1144 | A description of the module/package/extension etc. |
1145 | |
1146 | =item * |
ac634a9a |
1147 | |
2e1d04bc |
1148 | A copyright notice - see below. |
1149 | |
1150 | =item * |
ac634a9a |
1151 | |
2e1d04bc |
1152 | Prerequisites - what else you may need to have. |
1153 | |
1154 | =item * |
ac634a9a |
1155 | |
2e1d04bc |
1156 | How to build it - possible changes to Makefile.PL etc. |
1157 | |
1158 | =item * |
ac634a9a |
1159 | |
2e1d04bc |
1160 | How to install it. |
1161 | |
1162 | =item * |
ac634a9a |
1163 | |
2e1d04bc |
1164 | Recent changes in this release, especially incompatibilities |
1165 | |
1166 | =item * |
ac634a9a |
1167 | |
2e1d04bc |
1168 | Changes / enhancements you plan to make in the future. |
1169 | |
1170 | =back |
1171 | |
1172 | If the README file seems to be getting too large you may wish to |
1173 | split out some of the sections into separate files: INSTALL, |
1174 | Copying, ToDo etc. |
1175 | |
1176 | =over 4 |
1177 | |
1178 | =item Adding a Copyright Notice. |
1179 | |
ac634a9a |
1180 | |
2e1d04bc |
1181 | How you choose to license your work is a personal decision. |
1182 | The general mechanism is to assert your Copyright and then make |
1183 | a declaration of how others may copy/use/modify your work. |
1184 | |
1185 | Perl, for example, is supplied with two types of licence: The GNU |
1186 | GPL and The Artistic Licence (see the files README, Copying, and |
1187 | Artistic). Larry has good reasons for NOT just using the GNU GPL. |
1188 | |
1189 | My personal recommendation, out of respect for Larry, Perl, and the |
1190 | Perl community at large is to state something simply like: |
1191 | |
1192 | Copyright (c) 1995 Your Name. All rights reserved. |
1193 | This program is free software; you can redistribute it and/or |
1194 | modify it under the same terms as Perl itself. |
1195 | |
1196 | This statement should at least appear in the README file. You may |
1197 | also wish to include it in a Copying file and your source files. |
1198 | Remember to include the other words in addition to the Copyright. |
1199 | |
ac634a9a |
1200 | =item * |
1201 | |
1202 | Give the module a version/issue/release number. |
2e1d04bc |
1203 | |
1204 | To be fully compatible with the Exporter and MakeMaker modules you |
1205 | should store your module's version number in a non-my package |
1206 | variable called $VERSION. This should be a floating point |
1207 | number with at least two digits after the decimal (i.e., hundredths, |
1208 | e.g, C<$VERSION = "0.01">). Don't use a "1.3.2" style version. |
1209 | See L<Exporter> for details. |
1210 | |
1211 | It may be handy to add a function or method to retrieve the number. |
1212 | Use the number in announcements and archive file names when |
1213 | releasing the module (ModuleName-1.02.tar.Z). |
1214 | See perldoc ExtUtils::MakeMaker.pm for details. |
1215 | |
ac634a9a |
1216 | =item * |
1217 | |
1218 | How to release and distribute a module. |
2e1d04bc |
1219 | |
1220 | It's good idea to post an announcement of the availability of your |
1221 | module (or the module itself if small) to the comp.lang.perl.announce |
1222 | Usenet newsgroup. This will at least ensure very wide once-off |
1223 | distribution. |
1224 | |
1225 | If possible, register the module with CPAN. You should |
1226 | include details of its location in your announcement. |
1227 | |
1228 | Some notes about ftp archives: Please use a long descriptive file |
1229 | name that includes the version number. Most incoming directories |
1230 | will not be readable/listable, i.e., you won't be able to see your |
1231 | file after uploading it. Remember to send your email notification |
1232 | message as soon as possible after uploading else your file may get |
1233 | deleted automatically. Allow time for the file to be processed |
1234 | and/or check the file has been processed before announcing its |
1235 | location. |
1236 | |
1237 | FTP Archives for Perl Modules: |
1238 | |
1239 | Follow the instructions and links on: |
1240 | |
4e860d0a |
1241 | http://www.cpan.org/modules/00modlist.long.html |
1242 | http://www.cpan.org/modules/04pause.html |
2e1d04bc |
1243 | |
1244 | or upload to one of these sites: |
1245 | |
1246 | https://pause.kbx.de/pause/ |
1247 | http://pause.perl.org/pause/ |
1248 | |
1249 | and notify <modules@perl.org>. |
1250 | |
1251 | By using the WWW interface you can ask the Upload Server to mirror |
1252 | your modules from your ftp or WWW site into your own directory on |
1253 | CPAN! |
1254 | |
1255 | Please remember to send me an updated entry for the Module list! |
1256 | |
ac634a9a |
1257 | =item * |
1258 | |
1259 | Take care when changing a released module. |
2e1d04bc |
1260 | |
1261 | Always strive to remain compatible with previous released versions. |
1262 | Otherwise try to add a mechanism to revert to the |
1263 | old behavior if people rely on it. Document incompatible changes. |
1264 | |
1265 | =back |
1266 | |
1267 | =back |
1268 | |
1269 | =head2 Guidelines for Converting Perl 4 Library Scripts into Modules |
1270 | |
1271 | =over 4 |
1272 | |
ac634a9a |
1273 | =item * |
1274 | |
1275 | There is no requirement to convert anything. |
2e1d04bc |
1276 | |
1277 | If it ain't broke, don't fix it! Perl 4 library scripts should |
1278 | continue to work with no problems. You may need to make some minor |
1279 | changes (like escaping non-array @'s in double quoted strings) but |
1280 | there is no need to convert a .pl file into a Module for just that. |
1281 | |
ac634a9a |
1282 | =item * |
1283 | |
1284 | Consider the implications. |
2e1d04bc |
1285 | |
1286 | All Perl applications that make use of the script will need to |
1287 | be changed (slightly) if the script is converted into a module. Is |
1288 | it worth it unless you plan to make other changes at the same time? |
1289 | |
ac634a9a |
1290 | =item * |
1291 | |
1292 | Make the most of the opportunity. |
2e1d04bc |
1293 | |
1294 | If you are going to convert the script to a module you can use the |
1295 | opportunity to redesign the interface. The guidelines for module |
1296 | creation above include many of the issues you should consider. |
1297 | |
ac634a9a |
1298 | =item * |
1299 | |
1300 | The pl2pm utility will get you started. |
2e1d04bc |
1301 | |
1302 | This utility will read *.pl files (given as parameters) and write |
1303 | corresponding *.pm files. The pl2pm utilities does the following: |
1304 | |
1305 | =over 10 |
1306 | |
1307 | =item * |
ac634a9a |
1308 | |
2e1d04bc |
1309 | Adds the standard Module prologue lines |
1310 | |
1311 | =item * |
ac634a9a |
1312 | |
2e1d04bc |
1313 | Converts package specifiers from ' to :: |
1314 | |
1315 | =item * |
ac634a9a |
1316 | |
2e1d04bc |
1317 | Converts die(...) to croak(...) |
1318 | |
1319 | =item * |
ac634a9a |
1320 | |
2e1d04bc |
1321 | Several other minor changes |
1322 | |
1323 | =back |
1324 | |
1325 | Being a mechanical process pl2pm is not bullet proof. The converted |
1326 | code will need careful checking, especially any package statements. |
1327 | Don't delete the original .pl file till the new .pm one works! |
1328 | |
1329 | =back |
1330 | |
1331 | =head2 Guidelines for Reusing Application Code |
1332 | |
1333 | =over 4 |
1334 | |
ac634a9a |
1335 | =item * |
1336 | |
1337 | Complete applications rarely belong in the Perl Module Library. |
1338 | |
1339 | =item * |
2e1d04bc |
1340 | |
ac634a9a |
1341 | Many applications contain some Perl code that could be reused. |
2e1d04bc |
1342 | |
1343 | Help save the world! Share your code in a form that makes it easy |
1344 | to reuse. |
1345 | |
ac634a9a |
1346 | =item * |
1347 | |
1348 | Break-out the reusable code into one or more separate module files. |
1349 | |
1350 | =item * |
1351 | |
1352 | Take the opportunity to reconsider and redesign the interfaces. |
2e1d04bc |
1353 | |
ac634a9a |
1354 | =item * |
2e1d04bc |
1355 | |
ac634a9a |
1356 | In some cases the 'application' can then be reduced to a small |
2e1d04bc |
1357 | |
1358 | fragment of code built on top of the reusable modules. In these cases |
1359 | the application could invoked as: |
1360 | |
1361 | % perl -e 'use Module::Name; method(@ARGV)' ... |
1362 | or |
1363 | % perl -mModule::Name ... (in perl5.002 or higher) |
1364 | |
1365 | =back |
1366 | |
1367 | =head1 NOTE |
1368 | |
1369 | Perl does not enforce private and public parts of its modules as you may |
1370 | have been used to in other languages like C++, Ada, or Modula-17. Perl |
1371 | doesn't have an infatuation with enforced privacy. It would prefer |
1372 | that you stayed out of its living room because you weren't invited, not |
1373 | because it has a shotgun. |
1374 | |
1375 | The module and its user have a contract, part of which is common law, |
1376 | and part of which is "written". Part of the common law contract is |
1377 | that a module doesn't pollute any namespace it wasn't asked to. The |
1378 | written contract for the module (A.K.A. documentation) may make other |
1379 | provisions. But then you know when you C<use RedefineTheWorld> that |
1380 | you're redefining the world and willing to take the consequences. |
1381 | EOF |
1382 | |
1383 | close MANIFEST or warn "$0: failed to close MANIFEST (../MANIFEST): $!"; |
1384 | close OUT or warn "$0: failed to close OUT (perlmodlib.tmp): $!"; |
1385 | |