perlmodlib.pod
来自「MSYS在windows下模拟了一个类unix的终端」· POD 代码 · 共 2,043 行 · 第 1/3 页
POD
2,043 行
ftp://ftp.cpan.org/CPAN/ ftp://cpan.nas.nasa.gov/pub/perl/CPAN/ ftp://ftp.digital.com/pub/plan/perl/CPAN/ http://www.kernel.org/pub/mirrors/cpan/ ftp://ftp.kernel.org/pub/mirrors/cpan/ http://www.perl.com/CPAN/ http://download.sourceforge.net/mirrors/CPAN/=item *Colorado ftp://ftp.cs.colorado.edu/pub/perl/CPAN/=item *Florida ftp://ftp.cise.ufl.edu/pub/perl/CPAN/=item *Georgia ftp://ftp.twoguys.org/CPAN/=item *Illinois http://www.neurogames.com/mirrors/CPAN http://uiarchive.uiuc.edu/mirrors/ftp/ftp.cpan.org/pub/CPAN/ ftp://uiarchive.uiuc.edu/mirrors/ftp/ftp.cpan.org/pub/CPAN/=item *Indiana ftp://ftp.uwsg.indiana.edu/pub/perl/CPAN/ http://cpan.nitco.com/ ftp://cpan.nitco.com/pub/CPAN/ ftp://cpan.in-span.net/ http://csociety-ftp.ecn.purdue.edu/pub/CPAN ftp://csociety-ftp.ecn.purdue.edu/pub/CPAN=item *Kentucky http://cpan.uky.edu/ ftp://cpan.uky.edu/pub/CPAN/=item *Massachusetts ftp://ftp.ccs.neu.edu/net/mirrors/ftp.funet.fi/pub/languages/perl/CPAN/ ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN/=item *New Jersey ftp://ftp.cpanel.net/pub/CPAN/=item *New York ftp://ftp.freesoftware.com/pub/perl/CPAN/ http://www.deao.net/mirrors/CPAN/ ftp://ftp.deao.net/pub/CPAN/ ftp://ftp.stealth.net/pub/mirrors/ftp.cpan.org/pub/CPAN/ http://mirror.nyc.anidea.com/CPAN/ ftp://mirror.nyc.anidea.com/pub/CPAN/ http://www.rge.com/pub/languages/perl/ ftp://ftp.rge.com/pub/languages/perl/ ftp://mirrors.cloud9.net/pub/mirrors/CPAN/=item *North Carolina ftp://ftp.duke.edu/pub/perl/=item *Ohio ftp://ftp.loaded.net/pub/CPAN/=item *Oklahoma ftp://ftp.ou.edu/mirrors/CPAN/=item *Oregon ftp://ftp.orst.edu/pub/packages/CPAN/=item *Pennsylvania http://ftp.epix.net/CPAN/ ftp://ftp.epix.net/pub/languages/perl/ ftp://carroll.cac.psu.edu/pub/CPAN/=item *Tennessee ftp://ftp.sunsite.utk.edu/pub/CPAN/=item *Texas http://ftp.sedl.org/pub/mirrors/CPAN/ http://jhcloos.com/pub/mirror/CPAN/ ftp://jhcloos.com/pub/mirror/CPAN/=item *Utah ftp://mirror.xmission.com/CPAN/=item *Virginia http://mirrors.rcn.net/pub/lang/CPAN/ ftp://mirrors.rcn.net/pub/lang/CPAN/ ftp://ruff.cs.jmu.edu/pub/CPAN/ http://perl.Liquidation.com/CPAN/=item *Washington http://cpan.llarian.net/ ftp://cpan.llarian.net/pub/CPAN/ ftp://ftp-mirror.internap.com/pub/CPAN/ ftp://ftp.spu.edu/pub/CPAN/=back=back=head2 Oceania=over 4=item *Australia http://ftp.planetmirror.com/pub/CPAN/ ftp://ftp.planetmirror.com/pub/CPAN/ ftp://mirror.aarnet.edu.au/pub/perl/CPAN/ ftp://cpan.topend.com.au/pub/CPAN/=item *New Zealand ftp://ftp.auckland.ac.nz/pub/perl/CPAN/=back=head2 South America=over 4=item *Argentina ftp://mirrors.bannerlandia.com.ar/mirrors/CPAN/=item *Brazil ftp://cpan.pop-mg.com.br/pub/CPAN/ ftp://ftp.matrix.com.br/pub/perl/ ftp://cpan.if.usp.br/pub/mirror/CPAN/=item *Chile ftp://ftp.psinet.cl/pub/programming/perl/CPAN/ ftp://sunsite.dcc.uchile.cl/pub/lang/perl/=backFor an up-to-date listing of CPAN sites,see http://www.cpan.org/SITES or ftp://www.cpan.org/SITES .=head1 Modules: Creation, Use, and Abuse(The following section is borrowed directly from Tim Bunce's modulesfile, available at your nearest CPAN site.)Perl implements a class using a package, but the presence of apackage doesn't imply the presence of a class. A package is just anamespace. A class is a package that provides subroutines that can beused as methods. A method is just a subroutine that expects, as itsfirst argument, either the name of a package (for "static" methods),or a reference to something (for "virtual" methods).A module is a file that (by convention) provides a class of the samename (sans the .pm), plus an import method in that class that can becalled to fetch exported symbols. This module may implement some ofits methods by loading dynamic C or C++ objects, but that should betotally transparent to the user of the module. Likewise, the modulemight set up an AUTOLOAD function to slurp in subroutine definitions ondemand, but this is also transparent. Only the F<.pm> file is required toexist. See L<perlsub>, L<perltoot>, and L<AutoLoader> for details aboutthe AUTOLOAD mechanism.=head2 Guidelines for Module Creation=over 4=item *Do similar modules already exist in some form?If so, please try to reuse the existing modules either in whole orby inheriting useful features into a new class. If this is notpractical try to get together with the module authors to work onextending or enhancing the functionality of the existing modules.A perfect example is the plethora of packages in perl4 for dealingwith command line options.If you are writing a module to expand an already existing set ofmodules, please coordinate with the author of the package. Ithelps if you follow the same naming scheme and module interactionscheme as the original author.=item *Try to design the new module to be easy to extend and reuse.Try to C<use warnings;> (or C<use warnings qw(...);>).Remember that you can add C<no warnings qw(...);> to individual blocksof code that need less warnings.Use blessed references. Use the two argument form of bless to blessinto the class name given as the first parameter of the constructor,e.g.,: sub new { my $class = shift; return bless {}, $class; }or even this if you'd like it to be used as either a staticor a virtual method. sub new { my $self = shift; my $class = ref($self) || $self; return bless {}, $class; }Pass arrays as references so more parameters can be added later(it's also faster). Convert functions into methods whereappropriate. Split large methods into smaller more flexible ones.Inherit methods from other modules if appropriate.Avoid class name tests like: C<die "Invalid" unless ref $ref eq 'FOO'>.Generally you can delete the C<eq 'FOO'> part with no harm at all.Let the objects look after themselves! Generally, avoid hard-wiredclass names as far as possible.Avoid C<< $r->Class::func() >> where using C<@ISA=qw(... Class ...)> andC<< $r->func() >> would work (see L<perlbot> for more details).Use autosplit so little used or newly added functions won't be aburden to programs that don't use them. Add test functions tothe module after __END__ either using AutoSplit or by saying: eval join('',<main::DATA>) || die $@ unless caller();Does your module pass the 'empty subclass' test? If you sayC<@SUBCLASS::ISA = qw(YOURCLASS);> your applications should be ableto use SUBCLASS in exactly the same way as YOURCLASS. For example,does your application still work if you change: C<$obj = new YOURCLASS;>into: C<$obj = new SUBCLASS;> ?Avoid keeping any state information in your packages. It makes itdifficult for multiple other packages to use yours. Keep stateinformation in objects.Always use B<-w>.Try to C<use strict;> (or C<use strict qw(...);>).Remember that you can add C<no strict qw(...);> to individual blocksof code that need less strictness.Always use B<-w>.Follow the guidelines in the perlstyle(1) manual.Always use B<-w>.=item *Some simple style guidelinesThe perlstyle manual supplied with Perl has many helpful points.Coding style is a matter of personal taste. Many people evolve theirstyle over several years as they learn what helps them write andmaintain good code. Here's one set of assorted suggestions thatseem to be widely used by experienced developers:Use underscores to separate words. It is generally easier to read$var_names_like_this than $VarNamesLikeThis, especially fornon-native speakers of English. It's also a simple rule that worksconsistently with VAR_NAMES_LIKE_THIS.Package/Module names are an exception to this rule. Perl informallyreserves lowercase module names for 'pragma' modules like integerand strict. Other modules normally begin with a capital letter anduse mixed case with no underscores (need to be short and portable).You may find it helpful to use letter case to indicate the scopeor nature of a variable. For example: $ALL_CAPS_HERE constants only (beware clashes with Perl vars) $Some_Caps_Here package-wide global/static $no_caps_here function scope my() or local() variablesFunction and method names seem to work best as all lowercase.e.g., C<< $obj->as_string() >>.You can use a leading underscore to indicate that a variable orfunction should not be used outside the package that defined it.=item *Select what to export.Do NOT export method names!Do NOT export anything else by default without a good reason!Exports pollute the namespace of the module user. If you mustexport try to use @EXPORT_OK in preference to @EXPORT and avoidshort or common names to reduce the risk of name clashes.Generally anything not exported is still accessible from outside themodule using the ModuleName::item_name (or C<< $blessed_ref->method >>)syntax. By convention you can use a leading underscore on names toindicate informally that they are 'internal' and not for public use.(It is actually possible to get private functions by saying:C<my $subref = sub { ... }; &$subref;>. But there's no way to call thatdirectly as a method, because a method must have a name in the symboltable.)As a general rule, if the module is trying to be object orientedthen export nothing. If it's just a collection of functions then@EXPORT_OK anything but use @EXPORT with caution.=item *Select a name for the module.This name should be as descriptive, accurate, and complete aspossible. Avoid any risk of ambiguity. Always try to use two ormore whole words. Generally the name should reflect what is specialabout what the module does rather than how it does it. Please usenested module names to group informally or categorize a module.There should be a very good reason for a module not to have a nested name.Module names should begin with a capital letter.Having 57 modules all called Sort will not make life easy for anyone(though having 23 called Sort::Quick is only marginally better :-).Imagine someone trying to install your module alongside many others.If in any doubt ask for suggestions in comp.lang.perl.misc.If you are developing a suite of related modules/classes it's goodpractice to use nested classes with a common prefix as this willavoid namespace clashes. For example: Xyz::Control, Xyz::View,Xyz::Model etc. Use the modules in this list as a naming guide.If adding a new module to a set, follow the original author'sstandards for naming modules and the interface to methods inthose modules.If developing modules for private internal or project specific use,that will never be released to the public, then you should ensurethat their names will not clash with any future public module. Youcan do this either by using the reserved Local::* category or byusing a category name that includes an underscore like Foo_Corp::*.To be portable each component of a module name should be limited to11 characters. If it might be used on MS-DOS then try to ensure each isunique in the first 8 characters. Nested modules make this easier.=item *Have you got it right?How do you know that you've made the right decisions? Have youpicked an interface design that will cause problems later? Haveyou picked the most appropriate name? Do you have any questions?The best way to know for sure, and pick up many helpful suggestions,is to ask someone who knows. Comp.lang.perl.misc is read by just aboutall the people who develop modules and it's the best place to ask.All you need to do is post a short summary of the module, itspurpose and interfaces. A few lines on each of the main methods isprobably enough. (If you post the whole module it might be ignoredby busy people - generally the very people you want to read it!)Don't worry about posting if you can't say when the module will beready - just say so in the message. It might be worth invitingothers to help you, they may be able to complete it for you!=item *README and other Additional Files.It's well known that software developers usually fully document thesoftware they write. If, however, the world is in urgent need ofyour software and there is not enough time to write the fulldocumentation please at least provide a README file containing:=over 10=item *A description of the module/package/extension etc.=item *A copyright notice - see below.=item *Prerequisites - what else you may need to have.=item *How to build it - possible changes to Makefile.PL etc.=item *How to install it.=item *Recent changes in this release, especially incompatibilities=item *Changes / enhancements you plan to make in the future.=backIf the README file seems to be getting too large you may wish tosplit out some of the sections into separate files: INSTALL,Copying, ToDo etc.=over 4=item Adding a Copyright Notice.How you choose to license your work is a personal decision.The general mechanism is to assert your Copyright and then makea declaration of how others may copy/use/modify your work.Perl, for example, is supplied with two types of licence: The GNUGPL and The Artistic Licence (see the files README, Copying, andArtistic). Larry has good reasons for NOT just using the GNU GPL.My personal recommendation, out of respect for Larry, Perl, and thePerl community at large is to state something simply like: Copyright (c) 1995 Your Name. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.This statement should at least appear in the README file. You mayalso wish to include it in a Copying file and your source files.Remember to include the other words in addition to the Copyright.=item *Give the module a version/issue/release number.To be fully compatible with the Exporter and MakeMaker modules youshould store your module's version number in a non-my packagevariable called $VERSION. This should be a floating pointnumber with at least two digits after the decimal (i.e., hundredths,e.g, C<$VERSION = "0.01">). Don't use a "1.3.2" style version.See L<Exporter> for details.It may be handy to add a function or method to retrieve the number.Use the number in announcements and archive file names whenreleasing the module (ModuleName-1.02.tar.Z).See perldoc ExtUtils::MakeMaker.pm for details.=item *How to release and distribute a module.It's good idea to post an announcement of the availability of yourmodule (or the module itself if small) to the comp.lang.perl.announceUsenet newsgroup. This will at least ensure very wide once-offdistribution.If possible, register the module with CPAN. You shouldinclude details of its location in your announcement.Some notes about ftp archives: Please use a long descriptive filename that includes the version number. Most incoming directorieswill not be readable/listable, i.e., you won't be able to see yourfile after uploading it. Remember to send your email notificationmessage as soon as possible after uploading else your file may getdeleted automatically. Allow time for the file to be processedand/or check the file has been processed before announcing itslocation.FTP Archives for Perl Modules:Follow the instructions and links on: http://www.cpan.org/modules/00modlist.long.html http://www.cpan.org/modules/04pause.htmlor upload to one of these sites: https://pause.kbx.de/pause/ http://pause.perl.org/pause/and notify <modules@perl.org>.By using the WWW interface you can ask the Upload Server to mirroryour modules from your ftp or WWW site into your own directory onCPAN!Please remember to send me an updated entry for the Module list!=item *Take care when changing a released module.Always strive to remain compatible with previous released versions.Otherwise try to add a mechanism to revert to theold behavior if people rely on it. Document incompatible changes.=back=back=head2 Guidelines for Converting Perl 4 Library Scripts into Modules=over 4=item *There is no requirement to convert anything.If it ain't broke, don't fix it! Perl 4 library scripts shouldcontinue to work with no problems. You may need to make some minorchanges (like escaping non-array @'s in double quoted strings) butthere is no need to convert a .pl file into a Module for just that.=item *Consider the implications.All Perl applications that make use of the script will need tobe changed (slightly) if the script is converted into a module. Isit worth it unless you plan to make other changes at the same time?=item *Make the most of the opportunity.If you are going to convert the script to a module you can use theopportunity to redesign the interface. The guidelines for modulecreation above include many of the issues you should consider.=item *The pl2pm utility will get you started.This utility will read *.pl files (given as parameters) and writecorresponding *.pm files. The pl2pm utilities does the following:=over 10=item *Adds the standard Module prologue lines=item *Converts package specifiers from ' to ::=item *Converts die(...) to croak(...)=item *Several other minor changes=backBeing a mechanical process pl2pm is not bullet proof. The convertedcode will need careful checking, especially any package statements.Don't delete the original .pl file till the new .pm one works!=back=head2 Guidelines for Reusing Application Code=over 4=item *Complete applications rarely belong in the Perl Module Library.=item *Many applications contain some Perl code that could be reused.Help save the world! Share your code in a form that makes it easyto reuse.=item *Break-out the reusable code into one or more separate module files.=item *Take the opportunity to reconsider and redesign the interfaces.=item *In some cases the 'application' can then be reduced to a smallfragment of code built on top of the reusable modules. In these casesthe application could invoked as: % perl -e 'use Module::Name; method(@ARGV)' ...or % perl -mModule::Name ... (in perl5.002 or higher)=back=head1 NOTEPerl does not enforce private and public parts of its modules as you mayhave been used to in other languages like C++, Ada, or Modula-17. Perldoesn't have an infatuation with enforced privacy. It would preferthat you stayed out of its living room because you weren't invited, notbecause it has a shotgun.The module and its user have a contract, part of which is common law,and part of which is "written". Part of the common law contract isthat a module doesn't pollute any namespace it wasn't asked to. Thewritten contract for the module (A.K.A. documentation) may make otherprovisions. But then you know when you C<use RedefineTheWorld> thatyou're redefining the world and willing to take the consequences.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?