Debian Codegraph @

upstream/opensuse-tumbleweed/man1/perlmodstyle.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "PERLMODSTYLE 1"
61 .TH PERLMODSTYLE 1 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 perlmodstyle \- Perl module style guide
68 .SH INTRODUCTION
69 .IX Header "INTRODUCTION"
70 This document attempts to describe the Perl Community\*(Aqs "best practice"
71 for writing Perl modules. It extends the recommendations found in
72 perlstyle , which should be considered required reading
73 before reading this document.
74 .PP
75 While this document is intended to be useful to all module authors, it is
76 particularly aimed at authors who wish to publish their modules on CPAN.
77 .PP
78 The focus is on elements of style which are visible to the users of a
79 module, rather than those parts which are only seen by the module\*(Aqs
80 developers. However, many of the guidelines presented in this document
81 can be extrapolated and applied successfully to a module\*(Aqs internals.
82 .PP
83 This document differs from perlnewmod in that it is a style guide
84 rather than a tutorial on creating CPAN modules. It provides a
85 checklist against which modules can be compared to determine whether
86 they conform to best practice, without necessarily describing in detail
87 how to achieve this.
88 .PP
89 All the advice contained in this document has been gleaned from
90 extensive conversations with experienced CPAN authors and users. Every
91 piece of advice given here is the result of previous mistakes. This
92 information is here to help you avoid the same mistakes and the extra
93 work that would inevitably be required to fix them.
94 .PP
95 The first section of this document provides an itemized checklist;
96 subsequent sections provide a more detailed discussion of the items on
97 the list. The final section, "Common Pitfalls", describes some of the
98 most popular mistakes made by CPAN authors.
99 .SH "QUICK CHECKLIST"
100 .IX Header "QUICK CHECKLIST"
101 For more detail on each item in this checklist, see below.
102 .SS "Before you start"
103 .IX Subsection "Before you start"
104 .IP \(bu 4
105 Don\*(Aqt re\-invent the wheel
106 .IP \(bu 4
107 Patch, extend or subclass an existing module where possible
108 .IP \(bu 4
109 Do one thing and do it well
110 .IP \(bu 4
111 Choose an appropriate name
112 .IP \(bu 4
113 Get feedback before publishing
114 .SS "The API"
115 .IX Subsection "The API"
116 .IP \(bu 4
117 API should be understandable by the average programmer
118 .IP \(bu 4
119 Simple methods for simple tasks
120 .IP \(bu 4
121 Separate functionality from output
122 .IP \(bu 4
123 Consistent naming of subroutines or methods
124 .IP \(bu 4
125 Use named parameters (a hash or hashref) when there are more than two
126 parameters
127 .SS Stability
128 .IX Subsection "Stability"
129 .IP \(bu 4
130 Ensure your module works under \f(CW\*(C`use strict\*(C'\fR and \f(CW\*(C`\-w\*(C'\fR
131 .IP \(bu 4
132 Stable modules should maintain backwards compatibility
133 .SS Documentation
134 .IX Subsection "Documentation"
135 .IP \(bu 4
136 Write documentation in POD
137 .IP \(bu 4
138 Document purpose, scope and target applications
139 .IP \(bu 4
140 Document each publicly accessible method or subroutine, including params and return values
141 .IP \(bu 4
142 Give examples of use in your documentation
143 .IP \(bu 4
144 Provide a README file and perhaps also release notes, changelog, etc
145 .IP \(bu 4
146 Provide links to further information (URL, email)
147 .SS "Release considerations"
148 .IX Subsection "Release considerations"
149 .IP \(bu 4
150 Specify pre\-requisites in Makefile.PL or Build.PL
151 .IP \(bu 4
152 Specify Perl version requirements with \f(CW\*(C`use\*(C'\fR
153 .IP \(bu 4
154 Include tests with your module
155 .IP \(bu 4
156 Choose a sensible and consistent version numbering scheme (X.YY is the common Perl module numbering scheme)
157 .IP \(bu 4
158 Increment the version number for every change, no matter how small
159 .IP \(bu 4
160 Package the module using "make dist"
161 .IP \(bu 4
162 Choose an appropriate license (GPL/Artistic is a good default)
163 .SH "BEFORE YOU START WRITING A MODULE"
164 .IX Header "BEFORE YOU START WRITING A MODULE"
165 Try not to launch headlong into developing your module without spending
166 some time thinking first. A little forethought may save you a vast
167 amount of effort later on.
168 .SS "Has it been done before?"
169 .IX Subsection "Has it been done before?"
170 You may not even need to write the module. Check whether it\*(Aqs already
171 been done in Perl, and avoid re\-inventing the wheel unless you have a
172 good reason.
173 .PP
174 Good places to look for pre\-existing modules include
175 MetaCPAN <https://metacpan.org> and asking on \f(CW\*(C`module\[email protected]\*(C'\fR
176 (<https://lists.perl.org/list/module\-authors.html>).
177 .PP
178 If an existing module \fBalmost\fR does what you want, consider writing a
179 patch, writing a subclass, or otherwise extending the existing module
180 rather than rewriting it.
181 .SS "Do one thing and do it well"
182 .IX Subsection "Do one thing and do it well"
183 At the risk of stating the obvious, modules are intended to be modular.
184 A Perl developer should be able to use modules to put together the
185 building blocks of their application. However, it\*(Aqs important that the
186 blocks are the right shape, and that the developer shouldn\*(Aqt have to use
187 a big block when all they need is a small one.
188 .PP
189 Your module should have a clearly defined scope which is no longer than
190 a single sentence. Can your module be broken down into a family of
191 related modules?
192 .PP
193 Bad example:
194 .PP
195 "FooBar.pm provides an implementation of the FOO protocol and the
196 related BAR standard."
197 .PP
198 Good example:
199 .PP
200 "Foo.pm provides an implementation of the FOO protocol. Bar.pm
201 implements the related BAR protocol."
202 .PP
203 This means that if a developer only needs a module for the BAR standard,
204 they should not be forced to install libraries for FOO as well.
205 .SS "What\*(Aqs in a name?"
206 .IX Subsection "What's in a name?"
207 Make sure you choose an appropriate name for your module early on. This
208 will help people find and remember your module, and make programming
209 with your module more intuitive.
210 .PP
211 When naming your module, consider the following:
212 .IP \(bu 4
213 Be descriptive (i.e. accurately describes the purpose of the module).
214 .IP \(bu 4
215 Be consistent with existing modules.
216 .IP \(bu 4
217 Reflect the functionality of the module, not the implementation.
218 .IP \(bu 4
219 Avoid starting a new top\-level hierarchy, especially if a suitable
220 hierarchy already exists under which you could place your module.
221 .SS "Get feedback before publishing"
222 .IX Subsection "Get feedback before publishing"
223 If you have never uploaded a module to CPAN before (and even if you have),
224 you are strongly encouraged to get feedback from people who are already
225 familiar with the module\*(Aqs application domain and the CPAN naming system.
226 Authors of similar modules, or modules with similar names, may be a good
227 place to start, as are community sites like
228 Perl Monks <https://www.perlmonks.org>.
229 .SH "DESIGNING AND WRITING YOUR MODULE"
230 .IX Header "DESIGNING AND WRITING YOUR MODULE"
231 Considerations for module design and coding:
232 .SS "To OO or not to OO?"
233 .IX Subsection "To OO or not to OO?"
234 Your module may be object oriented (OO) or not, or it may have both kinds
235 of interfaces available. There are pros and cons of each technique, which
236 should be considered when you design your API.
237 .PP
238 In \fIPerl Best Practices\fR (copyright 2004, Published by O\*(AqReilly Media, Inc.),
239 Damian Conway provides a list of criteria to use when deciding if OO is the
240 right fit for your problem:
241 .IP \(bu 4
242 The system being designed is large, or is likely to become large.
243 .IP \(bu 4
244 The data can be aggregated into obvious structures, especially if
245 there\*(Aqs a large amount of data in each aggregate.
246 .IP \(bu 4
247 The various types of data aggregate form a natural hierarchy that
248 facilitates the use of inheritance and polymorphism.
249 .IP \(bu 4
250 You have a piece of data on which many different operations are
251 applied.
252 .IP \(bu 4
253 You need to perform the same general operations on related types of
254 data, but with slight variations depending on the specific type of data
255 the operations are applied to.
256 .IP \(bu 4
257 It\*(Aqs likely you\*(Aqll have to add new data types later.
258 .IP \(bu 4
259 The typical interactions between pieces of data are best represented by
260 operators.
261 .IP \(bu 4
262 The implementation of individual components of the system is likely to
263 change over time.
264 .IP \(bu 4
265 The system design is already object\-oriented.
266 .IP \(bu 4
267 Large numbers of other programmers will be using your code modules.
268 .PP
269 Think carefully about whether OO is appropriate for your module.
270 Gratuitous object orientation results in complex APIs which are
271 difficult for the average module user to understand or use.
272 .SS "Designing your API"
273 .IX Subsection "Designing your API"
274 Your interfaces should be understandable by an average Perl programmer.
275 The following guidelines may help you judge whether your API is
276 sufficiently straightforward:
277 .IP "Write simple routines to do simple things." 4
278 .IX Item "Write simple routines to do simple things."
279 It\*(Aqs better to have numerous simple routines than a few monolithic ones.
280 If your routine changes its behaviour significantly based on its
281 arguments, it\*(Aqs a sign that you should have two (or more) separate
282 routines.
283 .IP "Separate functionality from output." 4
284 .IX Item "Separate functionality from output."
285 Return your results in the most generic form possible and allow the user
286 to choose how to use them. The most generic form possible is usually a
287 Perl data structure which can then be used to generate a text report,
288 HTML, XML, a database query, or whatever else your users require.
289 .Sp
290 If your routine iterates through some kind of list (such as a list of
291 files, or records in a database) you may consider providing a callback
292 so that users can manipulate each element of the list in turn.
293 File::Find provides an example of this with its
294 \&\f(CW\*(C`find(\e&wanted, $dir)\*(C'\fR syntax.
295 .IP "Provide sensible shortcuts and defaults." 4
296 .IX Item "Provide sensible shortcuts and defaults."
297 Don\*(Aqt require every module user to jump through the same hoops to achieve a
298 simple result. You can always include optional parameters or routines for
299 more complex or non\-standard behaviour. If most of your users have to
300 type a few almost identical lines of code when they start using your
301 module, it\*(Aqs a sign that you should have made that behaviour a default.
302 Another good indicator that you should use defaults is if most of your
303 users call your routines with the same arguments.
304 .IP "Naming conventions" 4
305 .IX Item "Naming conventions"
306 Your naming should be consistent. For instance, it\*(Aqs better to have:
307 .Sp
308 .Vb 3
309 \& display_day();
310 \& display_week();
311 \& display_year();
312 .Ve
313 .Sp
314 than
315 .Sp
316 .Vb 3
317 \& display_day();
318 \& week_display();
319 \& show_year();
320 .Ve
321 .Sp
322 This applies equally to method names, parameter names, and anything else
323 which is visible to the user (and most things that aren\*(Aqt!)
324 .IP "Parameter passing" 4
325 .IX Item "Parameter passing"
326 Use named parameters. It\*(Aqs easier to use a hash like this:
327 .Sp
328 .Vb 5
329 \& $obj\->do_something(
330 \& name => "wibble",
331 \& type => "text",
332 \& size => 1024,
333 \& );
334 .Ve
335 .Sp
336 \&... than to have a long list of unnamed parameters like this:
337 .Sp
338 .Vb 1
339 \& $obj\->do_something("wibble", "text", 1024);
340 .Ve
341 .Sp
342 While the list of arguments might work fine for one, two or even three
343 arguments, any more arguments become hard for the module user to
344 remember, and hard for the module author to manage. If you want to add
345 a new parameter you will have to add it to the end of the list for
346 backward compatibility, and this will probably make your list order
347 unintuitive. Also, if many elements may be undefined you may see the
348 following unattractive method calls:
349 .Sp
350 .Vb 1
351 \& $obj\->do_something(undef, undef, undef, undef, undef, 1024);
352 .Ve
353 .Sp
354 Provide sensible defaults for parameters which have them. Don\*(Aqt make
355 your users specify parameters which will almost always be the same.
356 .Sp
357 The issue of whether to pass the arguments in a hash or a hashref is
358 largely a matter of personal style.
359 .Sp
360 The use of hash keys starting with a hyphen (\f(CW\*(C`\-name\*(C'\fR) or entirely in
361 upper case (\f(CW\*(C`NAME\*(C'\fR) is a relic of older versions of Perl in which
362 ordinary lower case strings were not handled correctly by the \f(CW\*(C`=>\*(C'\fR
363 operator. While some modules retain uppercase or hyphenated argument
364 keys for historical reasons or as a matter of personal style, most new
365 modules should use simple lower case keys. Whatever you choose, be
366 consistent!
367 .SS "Strictness and warnings"
368 .IX Subsection "Strictness and warnings"
369 Your module should run successfully under the strict pragma and should
370 run without generating any warnings. Your module should also handle
371 taint\-checking where appropriate, though this can cause difficulties in
372 many cases.
373 .SS "Backwards compatibility"
374 .IX Subsection "Backwards compatibility"
375 Modules which are "stable" should not break backwards compatibility
376 without at least a long transition phase and a major change in version
377 number.
378 .SS "Error handling and messages"
379 .IX Subsection "Error handling and messages"
380 When your module encounters an error it should do one or more of:
381 .IP \(bu 4
382 Return an undefined value.
383 .IP \(bu 4
384 set \f(CW$Module::errstr\fR or similar (\f(CW\*(C`errstr\*(C'\fR is a common name used by
385 DBI and other popular modules; if you choose something else, be sure to
386 document it clearly).
387 .IP \(bu 4
388 \&\f(CWwarn()\fR or \f(CWcarp()\fR a message to STDERR.
389 .IP \(bu 4
390 \&\f(CWcroak()\fR only when your module absolutely cannot figure out what to
391 do. (\f(CWcroak()\fR is a better version of \f(CWdie()\fR for use within
392 modules, which reports its errors from the perspective of the caller.
393 See Carp for details of \f(CWcroak()\fR, \f(CWcarp()\fR and other useful
394 routines.)
395 .IP \(bu 4
396 As an alternative to the above, you may prefer to throw exceptions using
397 the Error module.
398 .PP
399 Configurable error handling can be very useful to your users. Consider
400 offering a choice of levels for warning and debug messages, an option to
401 send messages to a separate file, a way to specify an error\-handling
402 routine, or other such features. Be sure to default all these options
403 to the commonest use.
404 .SH "DOCUMENTING YOUR MODULE"
405 .IX Header "DOCUMENTING YOUR MODULE"
406 .SS POD
407 .IX Subsection "POD"
408 Your module should include documentation aimed at Perl developers.
409 You should use Perl\*(Aqs "plain old documentation" (POD) for your general
410 technical documentation, though you may wish to write additional
411 documentation (white papers, tutorials, etc) in some other format.
412 You need to cover the following subjects:
413 .IP \(bu 4
414 A synopsis of the common uses of the module
415 .IP \(bu 4
416 The purpose, scope and target applications of your module
417 .IP \(bu 4
418 Use of each publicly accessible method or subroutine, including
419 parameters and return values
420 .IP \(bu 4
421 Examples of use
422 .IP \(bu 4
423 Sources of further information
424 .IP \(bu 4
425 A contact email address for the author/maintainer
426 .PP
427 The level of detail in Perl module documentation generally goes from
428 less detailed to more detailed. Your SYNOPSIS section should contain a
429 minimal example of use (perhaps as little as one line of code; skip the
430 unusual use cases or anything not needed by most users); the
431 DESCRIPTION should describe your module in broad terms, generally in
432 just a few paragraphs; more detail of the module\*(Aqs routines or methods,
433 lengthy code examples, or other in\-depth material should be given in
434 subsequent sections.
435 .PP
436 Ideally, someone who\*(Aqs slightly familiar with your module should be able
437 to refresh their memory without hitting "page down". As your reader
438 continues through the document, they should receive a progressively
439 greater amount of knowledge.
440 .PP
441 The recommended order of sections in Perl module documentation is:
442 .IP \(bu 4
443 NAME
444 .IP \(bu 4
445 SYNOPSIS
446 .IP \(bu 4
447 DESCRIPTION
448 .IP \(bu 4
449 One or more sections or subsections giving greater detail of available
450 methods and routines and any other relevant information.
451 .IP \(bu 4
452 BUGS/CAVEATS/etc
453 .IP \(bu 4
454 AUTHOR
455 .IP \(bu 4
456 SEE ALSO
457 .IP \(bu 4
458 COPYRIGHT and LICENSE
459 .PP
460 Keep your documentation near the code it documents ("inline"
461 documentation). Include POD for a given method right above that
462 method\*(Aqs subroutine. This makes it easier to keep the documentation up
463 to date, and avoids having to document each piece of code twice (once in
464 POD and once in comments).
465 .SS "README, INSTALL, release notes, changelogs"
466 .IX Subsection "README, INSTALL, release notes, changelogs"
467 Your module should also include a README file describing the module and
468 giving pointers to further information (website, author email).
469 .PP
470 An INSTALL file should be included, and should contain simple installation
471 instructions. When using ExtUtils::MakeMaker this will usually be:
472 .IP "perl Makefile.PL" 4
473 .IX Item "perl Makefile.PL"
474 .PD 0
475 .IP make 4
476 .IX Item "make"
477 .IP "make test" 4
478 .IX Item "make test"
479 .IP "make install" 4
480 .IX Item "make install"
481 .PD
482 .PP
483 When using Module::Build, this will usually be:
484 .IP "perl Build.PL" 4
485 .IX Item "perl Build.PL"
486 .PD 0
487 .IP "perl Build" 4
488 .IX Item "perl Build"
489 .IP "perl Build test" 4
490 .IX Item "perl Build test"
491 .IP "perl Build install" 4
492 .IX Item "perl Build install"
493 .PD
494 .PP
495 Release notes or changelogs should be produced for each release of your
496 software describing user\-visible changes to your module, in terms
497 relevant to the user.
498 .PP
499 Unless you have good reasons for using some other format
500 (for example, a format used within your company),
501 the convention is to name your changelog file \f(CW\*(C`Changes\*(C'\fR,
502 and to follow the simple format described in CPAN::Changes::Spec.
503 .SH "RELEASE CONSIDERATIONS"
504 .IX Header "RELEASE CONSIDERATIONS"
505 .SS "Version numbering"
506 .IX Subsection "Version numbering"
507 Version numbers should indicate at least major and minor releases, and
508 possibly sub\-minor releases. A major release is one in which most of
509 the functionality has changed, or in which major new functionality is
510 added. A minor release is one in which a small amount of functionality
511 has been added or changed. Sub\-minor version numbers are usually used
512 for changes which do not affect functionality, such as documentation
513 patches.
514 .PP
515 The most common CPAN version numbering scheme looks like this:
516 .PP
517 .Vb 1
518 \& 1.00, 1.10, 1.11, 1.20, 1.30, 1.31, 1.32
519 .Ve
520 .PP
521 A correct CPAN version number is a floating point number with at least
522 2 digits after the decimal. You can test whether it conforms to CPAN by
523 using
524 .PP
525 .Vb 2
526 \& perl \-MExtUtils::MakeMaker \-le \*(Aqprint MM\->parse_version(shift)\*(Aq \e
527 \& \*(AqFoo.pm\*(Aq
528 .Ve
529 .PP
530 If you want to release a \*(Aqbeta\*(Aq or \*(Aqalpha\*(Aq version of a module but
531 don\*(Aqt want CPAN.pm to list it as most recent use an \*(Aq_\*(Aq after the
532 regular version number followed by at least 2 digits, eg. 1.20_01. If
533 you do this, the following idiom is recommended:
534 .PP
535 .Vb 5
536 \& our $VERSION = "1.12_01"; # so CPAN distribution will have
537 \& # right filename
538 \& our $XS_VERSION = $VERSION; # only needed if you have XS code
539 \& $VERSION = eval $VERSION; # so "use Module 0.002" won\*(Aqt warn on
540 \& # underscore
541 .Ve
542 .PP
543 With that trick MakeMaker will only read the first line and thus read
544 the underscore, while the perl interpreter will evaluate the \f(CW$VERSION\fR
545 and convert the string into a number. Later operations that treat
546 \&\f(CW$VERSION\fR as a number will then be able to do so without provoking a
547 warning about \f(CW$VERSION\fR not being a number.
548 .PP
549 Never release anything (even a one\-word documentation patch) without
550 incrementing the number. Even a one\-word documentation patch should
551 result in a change in version at the sub\-minor level.
552 .PP
553 Once picked, it is important to stick to your version scheme, without
554 reducing the number of digits. This is because "downstream" packagers,
555 such as the FreeBSD ports system, interpret the version numbers in
556 various ways. If you change the number of digits in your version scheme,
557 you can confuse these systems so they get the versions of your module
558 out of order, which is obviously bad.
559 .SS Pre\-requisites
560 .IX Subsection "Pre-requisites"
561 Module authors should carefully consider whether to rely on other
562 modules, and which modules to rely on.
563 .PP
564 Most importantly, choose modules which are as stable as possible. In
565 order of preference:
566 .IP \(bu 4
567 Core Perl modules
568 .IP \(bu 4
569 Stable CPAN modules
570 .IP \(bu 4
571 Unstable CPAN modules
572 .IP \(bu 4
573 Modules not available from CPAN
574 .PP
575 Specify version requirements for other Perl modules in the
576 pre\-requisites in your Makefile.PL or Build.PL.
577 .PP
578 Be sure to specify Perl version requirements both in Makefile.PL or
579 Build.PL and with \f(CW\*(C`require 5.6.1\*(C'\fR or similar. See the documentation on
580 \&\f(CW\*(C`use VERSION\*(C'\fR for details.
581 .SS Testing
582 .IX Subsection "Testing"
583 All modules should be tested before distribution (using "make disttest"),
584 and the tests should also be available to people installing the modules
585 (using "make test").
586 For Module::Build you would use the \f(CW\*(C`make test\*(C'\fR equivalent \f(CW\*(C`perl Build test\*(C'\fR.
587 .PP
588 The importance of these tests is proportional to the alleged stability of a
589 module. A module which purports to be
590 stable or which hopes to achieve wide
591 use should adhere to as strict a testing regime as possible.
592 .PP
593 Useful modules to help you write tests (with minimum impact on your
594 development process or your time) include Test::Simple, Carp::Assert
595 and Test::Inline.
596 For more sophisticated test suites there are Test::More and Test::MockObject.
597 .SS Packaging
598 .IX Subsection "Packaging"
599 Modules should be packaged using one of the standard packaging tools.
600 Currently you have the choice between ExtUtils::MakeMaker and the
601 more platform independent Module::Build, allowing modules to be installed in a
602 consistent manner.
603 When using ExtUtils::MakeMaker, you can use "make dist" to create your
604 package. Tools exist to help you to build your module in a
605 MakeMaker\-friendly style. These include ExtUtils::ModuleMaker and h2xs.
606 See also perlnewmod.
607 .SS Licensing
608 .IX Subsection "Licensing"
609 Make sure that your module has a license, and that the full text of it
610 is included in the distribution (unless it\*(Aqs a common one and the terms
611 of the license don\*(Aqt require you to include it).
612 .PP
613 If you don\*(Aqt know what license to use, dual licensing under the GPL
614 and Artistic licenses (the same as Perl itself) is a good idea.
615 See perlgpl and perlartistic.
616 .SH "COMMON PITFALLS"
617 .IX Header "COMMON PITFALLS"
618 .SS "Reinventing the wheel"
619 .IX Subsection "Reinventing the wheel"
620 There are certain application spaces which are already very, very well
621 served by CPAN. One example is templating systems, another is date and
622 time modules, and there are many more. While it is a rite of passage to
623 write your own version of these things, please consider carefully
624 whether the Perl world really needs you to publish it.
625 .SS "Trying to do too much"
626 .IX Subsection "Trying to do too much"
627 Your module will be part of a developer\*(Aqs toolkit. It will not, in
628 itself, form the \fBentire\fR toolkit. It\*(Aqs tempting to add extra features
629 until your code is a monolithic system rather than a set of modular
630 building blocks.
631 .SS "Inappropriate documentation"
632 .IX Subsection "Inappropriate documentation"
633 Don\*(Aqt fall into the trap of writing for the wrong audience. Your
634 primary audience is a reasonably experienced developer with at least
635 a moderate understanding of your module\*(Aqs application domain, who\*(Aqs just
636 downloaded your module and wants to start using it as quickly as possible.
637 .PP
638 Tutorials, end\-user documentation, research papers, FAQs etc are not
639 appropriate in a module\*(Aqs main documentation. If you really want to
640 write these, include them as sub\-documents such as \f(CW\*(C`My::Module::Tutorial\*(C'\fR or
641 \&\f(CW\*(C`My::Module::FAQ\*(C'\fR and provide a link in the SEE ALSO section of the
642 main documentation.
643 .SH "SEE ALSO"
644 .IX Header "SEE ALSO"
645 .IP perlstyle 4
646 .IX Item "perlstyle"
647 General Perl style guide
648 .IP perlnewmod 4
649 .IX Item "perlnewmod"
650 How to create a new module
651 .IP perlpod 4
652 .IX Item "perlpod"
653 POD documentation
654 .IP podchecker 4
655 .IX Item "podchecker"
656 Verifies your POD\*(Aqs correctness
657 .IP "Packaging Tools" 4
658 .IX Item "Packaging Tools"
659 ExtUtils::MakeMaker, Module::Build
660 .IP "Testing tools" 4
661 .IX Item "Testing tools"
662 Test::Simple, Test::Inline, Carp::Assert, Test::More, Test::MockObject
663 .IP <https://pause.perl.org/> 4
664 .IX Item "<https://pause.perl.org/>"
665 Perl Authors Upload Server. Contains links to information for module
666 authors.
667 .IP "Any good book on software engineering" 4
668 .IX Item "Any good book on software engineering"
669 .SH AUTHOR
670 .IX Header "AUTHOR"
671 Kirrily "Skud" Robert <[email protected]>