⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perlmodstyle.1

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 1
📖 第 1 页 / 共 2 页
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings.  \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote.  \*(C+ will.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\.    ds -- \(*W-.    ds PI pi.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch.    ds L" "".    ds R" "".    ds C` "".    ds C' ""'br\}.el\{\.    ds -- \|\(em\|.    ds PI \(*p.    ds L" ``.    ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el       .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD.  Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\.    de IX.    tm Index:\\$1\t\\n%\t"\\$2"...    nr % 0.    rr F.\}.el \{\.    de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear.  Run.  Save yourself.  No user-serviceable parts..    \" fudge factors for nroff and troff.if n \{\.    ds #H 0.    ds #V .8m.    ds #F .3m.    ds #[ \f1.    ds #] \fP.\}.if t \{\.    ds #H ((1u-(\\\\n(.fu%2u))*.13m).    ds #V .6m.    ds #F 0.    ds #[ \&.    ds #] \&.\}.    \" simple accents for nroff and troff.if n \{\.    ds ' \&.    ds ` \&.    ds ^ \&.    ds , \&.    ds ~ ~.    ds /.\}.if t \{\.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u".    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}.    \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E.    \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'.    \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\.    ds : e.    ds 8 ss.    ds o a.    ds d- d\h'-1'\(ga.    ds D- D\h'-1'\(hy.    ds th \o'bp'.    ds Th \o'LP'.    ds ae ae.    ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "PERLMODSTYLE 1".TH PERLMODSTYLE 1 "2007-12-18" "perl v5.10.0" "Perl Programmers Reference Guide".\" For nroff, turn off justification.  Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"perlmodstyle \- Perl module style guide.SH "INTRODUCTION".IX Header "INTRODUCTION"This document attempts to describe the Perl Community's \*(L"best practice\*(R"for writing Perl modules.  It extends the recommendations found in perlstyle , which should be considered required readingbefore reading this document..PPWhile this document is intended to be useful to all module authors, it isparticularly aimed at authors who wish to publish their modules on \s-1CPAN\s0..PPThe focus is on elements of style which are visible to the users of a module, rather than those parts which are only seen by the module's developers.  However, many of the guidelines presented in this documentcan be extrapolated and applied successfully to a module's internals..PPThis document differs from perlnewmod in that it is a style guiderather than a tutorial on creating \s-1CPAN\s0 modules.  It provides achecklist against which modules can be compared to determine whetherthey conform to best practice, without necessarily describing in detailhow to achieve this..PPAll the advice contained in this document has been gleaned fromextensive conversations with experienced \s-1CPAN\s0 authors and users.  Everypiece of advice given here is the result of previous mistakes.  Thisinformation is here to help you avoid the same mistakes and the extrawork that would inevitably be required to fix them..PPThe first section of this document provides an itemized checklist; subsequent sections provide a more detailed discussion of the items on the list.  The final section, \*(L"Common Pitfalls\*(R", describes some of the most popular mistakes made by \s-1CPAN\s0 authors..SH "QUICK CHECKLIST".IX Header "QUICK CHECKLIST"For more detail on each item in this checklist, see below..Sh "Before you start".IX Subsection "Before you start".IP "\(bu" 4Don't re-invent the wheel.IP "\(bu" 4Patch, extend or subclass an existing module where possible.IP "\(bu" 4Do one thing and do it well.IP "\(bu" 4Choose an appropriate name.Sh "The \s-1API\s0".IX Subsection "The API".IP "\(bu" 4\&\s-1API\s0 should be understandable by the average programmer.IP "\(bu" 4Simple methods for simple tasks.IP "\(bu" 4Separate functionality from output.IP "\(bu" 4Consistent naming of subroutines or methods.IP "\(bu" 4Use named parameters (a hash or hashref) when there are more than twoparameters.Sh "Stability".IX Subsection "Stability".IP "\(bu" 4Ensure your module works under \f(CW\*(C`use strict\*(C'\fR and \f(CW\*(C`\-w\*(C'\fR.IP "\(bu" 4Stable modules should maintain backwards compatibility.Sh "Documentation".IX Subsection "Documentation".IP "\(bu" 4Write documentation in \s-1POD\s0.IP "\(bu" 4Document purpose, scope and target applications.IP "\(bu" 4Document each publically accessible method or subroutine, including params and return values.IP "\(bu" 4Give examples of use in your documentation.IP "\(bu" 4Provide a \s-1README\s0 file and perhaps also release notes, changelog, etc.IP "\(bu" 4Provide links to further information (\s-1URL\s0, email).Sh "Release considerations".IX Subsection "Release considerations".IP "\(bu" 4Specify pre-requisites in Makefile.PL or Build.PL.IP "\(bu" 4Specify Perl version requirements with \f(CW\*(C`use\*(C'\fR.IP "\(bu" 4Include tests with your module.IP "\(bu" 4Choose a sensible and consistent version numbering scheme (X.YY is the common Perl module numbering scheme).IP "\(bu" 4Increment the version number for every change, no matter how small.IP "\(bu" 4Package the module using \*(L"make dist\*(R".IP "\(bu" 4Choose an appropriate license (GPL/Artistic is a good default).SH "BEFORE YOU START WRITING A MODULE".IX Header "BEFORE YOU START WRITING A MODULE"Try not to launch headlong into developing your module without spendingsome time thinking first.  A little forethought may save you a vastamount of effort later on..Sh "Has it been done before?".IX Subsection "Has it been done before?"You may not even need to write the module.  Check whether it's already been done in Perl, and avoid re-inventing the wheel unless you have a good reason..PPGood places to look for pre-existing modules includehttp://search.cpan.org/ and asking on modules@perl.org.PPIf an existing module \fBalmost\fR does what you want, consider writing apatch, writing a subclass, or otherwise extending the existing modulerather than rewriting it..Sh "Do one thing and do it well".IX Subsection "Do one thing and do it well"At the risk of stating the obvious, modules are intended to be modular.A Perl developer should be able to use modules to put together thebuilding blocks of their application.  However, it's important that theblocks are the right shape, and that the developer shouldn't have to usea big block when all they need is a small one..PPYour module should have a clearly defined scope which is no longer thana single sentence.  Can your module be broken down into a family ofrelated modules?.PPBad example:.PP\&\*(L"FooBar.pm provides an implementation of the \s-1FOO\s0 protocol and therelated \s-1BAR\s0 standard.\*(R".PPGood example:.PP\&\*(L"Foo.pm provides an implementation of the \s-1FOO\s0 protocol.  Bar.pmimplements the related \s-1BAR\s0 protocol.\*(R".PPThis means that if a developer only needs a module for the \s-1BAR\s0 standard,they should not be forced to install libraries for \s-1FOO\s0 as well..Sh "What's in a name?".IX Subsection "What's in a name?"Make sure you choose an appropriate name for your module early on.  Thiswill help people find and remember your module, and make programmingwith your module more intuitive..PPWhen naming your module, consider the following:.IP "\(bu" 4Be descriptive (i.e. accurately describes the purpose of the module)..IP "\(bu" 4Be consistent with existing modules..IP "\(bu" 4Reflect the functionality of the module, not the implementation..IP "\(bu" 4Avoid starting a new top-level hierarchy, especially if a suitablehierarchy already exists under which you could place your module..PPYou should contact modules@perl.org to ask them about your module namebefore publishing your module.  You should also try to ask people who are already familiar with the module's application domain and the \s-1CPAN\s0naming system.  Authors of similar modules, or modules with similarnames, may be a good place to start..SH "DESIGNING AND WRITING YOUR MODULE".IX Header "DESIGNING AND WRITING YOUR MODULE"Considerations for module design and coding:.Sh "To \s-1OO\s0 or not to \s-1OO\s0?".IX Subsection "To OO or not to OO?"Your module may be object oriented (\s-1OO\s0) or not, or it may have both kinds of interfaces available.  There are pros and cons of each technique, which should be considered when you design your \s-1API\s0..PPAccording to Damian Conway, you should consider using \s-1OO:\s0.IP "\(bu" 4When the system is large or likely to become so.IP "\(bu" 4When the data is aggregated in obvious structures that will become objects.IP "\(bu" 4When the types of data form a natural hierarchy that can make use of inheritance.IP "\(bu" 4When operations on data vary according to data type (makingpolymorphic invocation of methods feasible).IP "\(bu" 4When it is likely that new data types may be later introducedinto the system, and will need to be handled by existing code.IP "\(bu" 4When interactions between data are best represented byoverloaded operators.IP "\(bu" 4When the implementation of system components is likely tochange over time (and hence should be encapsulated).IP "\(bu" 4When the system design is itself object-oriented.IP "\(bu" 4When large amounts of client code will use the software (andshould be insulated from changes in its implementation).IP "\(bu" 4When many separate operations will need to be applied to thesame set of data.PPThink carefully about whether \s-1OO\s0 is appropriate for your module.Gratuitous object orientation results in complex APIs which aredifficult for the average module user to understand or use..Sh "Designing your \s-1API\s0".IX Subsection "Designing your API"Your interfaces should be understandable by an average Perl programmer.  The following guidelines may help you judge whether your \s-1API\s0 issufficiently straightforward:.IP "Write simple routines to do simple things." 4.IX Item "Write simple routines to do simple things."It's better to have numerous simple routines than a few monolithic ones.If your routine changes its behaviour significantly based on itsarguments, it's a sign that you should have two (or more) separateroutines..IP "Separate functionality from output." 4.IX Item "Separate functionality from output."Return your results in the most generic form possible and allow the user to choose how to use them.  The most generic form possible is usually aPerl data structure which can then be used to generate a text report,\&\s-1HTML\s0, \s-1XML\s0, a database query, or whatever else your users require..SpIf your routine iterates through some kind of list (such as a list offiles, or records in a database) you may consider providing a callbackso that users can manipulate each element of the list in turn.File::Find provides an example of this with its \&\f(CW\*(C`find(\e&wanted, $dir)\*(C'\fR syntax..IP "Provide sensible shortcuts and defaults." 4

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -