📄 module::load::conditional.3
字号:
.\" 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 "Module::Load::Conditional 3".TH Module::Load::Conditional 3 "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"Module::Load::Conditional \- Looking up module information / loading at runtime.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 1\& use Module::Load::Conditional qw[can_load check_install requires];\&\&\& my $use_list = {\& CPANPLUS => 0.05,\& LWP => 5.60,\& \*(AqTest::More\*(Aq => undef,\& };\&\& print can_load( modules => $use_list )\& ? \*(Aqall modules loaded successfully\*(Aq\& : \*(Aqfailed to load required modules\*(Aq;\&\&\& my $rv = check_install( module => \*(AqLWP\*(Aq, version => 5.60 )\& or print \*(AqLWP is not installed!\*(Aq;\&\& print \*(AqLWP up to date\*(Aq if $rv\->{uptodate};\& print "LWP version is $rv\->{version}\en";\& print "LWP is installed as file $rv\->{file}\en";\&\&\& print "LWP requires the following modules to be installed:\en";\& print join "\en", requires(\*(AqLWP\*(Aq);\&\& ### allow M::L::C to peek in your %INC rather than just\& ### scanning @INC\& $Module::Load::Conditional::CHECK_INC_HASH = 1;\&\& ### reset the \*(Aqcan_load\*(Aq cache\& undef $Module::Load::Conditional::CACHE;\&\& ### don\*(Aqt have Module::Load::Conditional issue warnings \-\-\& ### default is \*(Aq1\*(Aq\& $Module::Load::Conditional::VERBOSE = 0;\&\& ### The last error that happened during a call to \*(Aqcan_load\*(Aq\& my $err = $Module::Load::Conditional::ERROR;.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"Module::Load::Conditional provides simple ways to query and possibly load any ofthe modules you have installed on your system during runtime..PPIt is able to load multiple modules at once or none at all if one ofthem was not able to load. It also takes care of any error checkingand so forth..SH "Methods".IX Header "Methods".ie n .SH "$href = check_install( module => NAME [, version => VERSION, verbose => BOOL ] );".el .SH "\f(CW$href\fP = check_install( module => NAME [, version => VERSION, verbose => BOOL ] );".IX Header "$href = check_install( module => NAME [, version => VERSION, verbose => BOOL ] );"\&\f(CW\*(C`check_install\*(C'\fR allows you to verify if a certain module is installedor not. You may call it with the following arguments:.IP "module" 4.IX Item "module"The name of the module you wish to verify \*(-- this is a required key.IP "version" 4.IX Item "version"The version this module needs to be \*(-- this is optional.IP "verbose" 4.IX Item "verbose"Whether or not to be verbose about what it is doing \*(-- it will defaultto \f(CW$Module::Load::Conditional::VERBOSE\fR.PPIt will return undef if it was not able to find where the module wasinstalled, or a hash reference with the following keys if it was ableto find the file:.IP "file" 4.IX Item "file"Full path to the file that contains the module.IP "version" 4.IX Item "version"The version number of the installed module \- this will be \f(CW\*(C`undef\*(C'\fR ifthe module had no (or unparsable) version number, or if the variable\&\f(CW$Module::Load::Conditional::FIND_VERSION\fR was set to true.(See the \f(CW\*(C`GLOBAL VARIABLES\*(C'\fR section below for details).IP "uptodate" 4.IX Item "uptodate"A boolean value indicating whether or not the module was found to beat least the version you specified. If you did not specify a version,uptodate will always be true if the module was found.If no parsable version was found in the module, uptodate will also betrue, since \f(CW\*(C`check_install\*(C'\fR had no way to verify clearly..ie n .Sh "$bool = can_load( modules => { \s-1NAME\s0 => \s-1VERSION\s0 [,NAME => \s-1VERSION\s0] }, [verbose => \s-1BOOL\s0, nocache => \s-1BOOL\s0] )".el .Sh "\f(CW$bool\fP = can_load( modules => { \s-1NAME\s0 => \s-1VERSION\s0 [,NAME => \s-1VERSION\s0] }, [verbose => \s-1BOOL\s0, nocache => \s-1BOOL\s0] )".IX Subsection "$bool = can_load( modules => { NAME => VERSION [,NAME => VERSION] }, [verbose => BOOL, nocache => BOOL] )"\&\f(CW\*(C`can_load\*(C'\fR will take a list of modules, optionally with versionnumbers and determine if it is able to load them. If it can load *ALL*of them, it will. If one or more are unloadable, none will be loaded..PPThis is particularly useful if you have More Than One Way (tm) tosolve a problem in a program, and only wish to continue down a pathif all modules could be loaded, and not load them if they couldn't..PPThis function uses the \f(CW\*(C`load\*(C'\fR function from Module::Load under thehood..PP\&\f(CW\*(C`can_load\*(C'\fR takes the following arguments:.IP "modules" 4.IX Item "modules"This is a hashref of module/version pairs. The version indicates theminimum version to load. If no version is provided, any version isassumed to be good enough..IP "verbose" 4.IX Item "verbose"This controls whether warnings should be printed if a module failedto load.The default is to use the value of \f(CW$Module::Load::Conditional::VERBOSE\fR..IP "nocache" 4.IX Item "nocache"\&\f(CW\*(C`can_load\*(C'\fR keeps its results in a cache, so it will not load thesame module twice, nor will it attempt to load a module that hasalready failed to load before. By default, \f(CW\*(C`can_load\*(C'\fR will check itscache, but you can override that by setting \f(CW\*(C`nocache\*(C'\fR to true..ie n .Sh "@list = requires( \s-1MODULE\s0 );".el .Sh "\f(CW@list\fP = requires( \s-1MODULE\s0 );".IX Subsection "@list = requires( MODULE );"\&\f(CW\*(C`requires\*(C'\fR can tell you what other modules a particular modulerequires. This is particularly useful when you're intending to writea module for public release and are listing its prerequisites..PP\&\f(CW\*(C`requires\*(C'\fR takes but one argument: the name of a module.It will then first check if it can actually load this module, andreturn undef if it can't.Otherwise, it will return a list of modules and pragmas that wouldhave been loaded on the module's behalf..PPNote: The list \f(CW\*(C`require\*(C'\fR returns has originated from your currentperl and your current install..SH "Global Variables".IX Header "Global Variables"The behaviour of Module::Load::Conditional can be altered by changing thefollowing global variables:.ie n .Sh "$Module::Load::Conditional::VERBOSE".el .Sh "\f(CW$Module::Load::Conditional::VERBOSE\fP".IX Subsection "$Module::Load::Conditional::VERBOSE"This controls whether Module::Load::Conditional will issue warnings andexplanations as to why certain things may have failed. If you set itto 0, Module::Load::Conditional will not output any warnings.The default is 0;.ie n .Sh "$Module::Load::Conditional::FIND_VERSION".el .Sh "\f(CW$Module::Load::Conditional::FIND_VERSION\fP".IX Subsection "$Module::Load::Conditional::FIND_VERSION"This controls whether Module::Load::Conditional will try to parse(and eval) the version from the module you're trying to load..PPIf you don't wish to do this, set this variable to \f(CW\*(C`false\*(C'\fR. Understandthen that version comparisons are not possible, and Module::Load::Conditionalcan not tell you what module version you have installed.This may be desirable from a security or performance point of view. Note that \f(CW$FIND_VERSION\fR code runs safely under \f(CW\*(C`taint mode\*(C'\fR..PPThe default is 1;.ie n .Sh "$Module::Load::Conditional::CHECK_INC_HASH".el .Sh "\f(CW$Module::Load::Conditional::CHECK_INC_HASH\fP".IX Subsection "$Module::Load::Conditional::CHECK_INC_HASH"This controls whether \f(CW\*(C`Module::Load::Conditional\*(C'\fR checks your\&\f(CW%INC\fR hash to see if a module is available. By default, only\&\f(CW@INC\fR is scanned to see if a module is physically on yourfilesystem, or avialable via an \f(CW\*(C`@INC\-hook\*(C'\fR. Setting this variableto \f(CW\*(C`true\*(C'\fR will trust any entries in \f(CW%INC\fR and return them foryou..PPThe default is 0;.ie n .Sh "$Module::Load::Conditional::CACHE".el .Sh "\f(CW$Module::Load::Conditional::CACHE\fP".IX Subsection "$Module::Load::Conditional::CACHE"This holds the cache of the \f(CW\*(C`can_load\*(C'\fR function. If you explicitlywant to remove the current cache, you can set this variable to\&\f(CW\*(C`undef\*(C'\fR.ie n .Sh "$Module::Load::Conditional::ERROR".el .Sh "\f(CW$Module::Load::Conditional::ERROR\fP".IX Subsection "$Module::Load::Conditional::ERROR"This holds a string of the last error that happened during a call to\&\f(CW\*(C`can_load\*(C'\fR. It is useful to inspect this when \f(CW\*(C`can_load\*(C'\fR returns\&\f(CW\*(C`undef\*(C'\fR..SH "See Also".IX Header "See Also"\&\f(CW\*(C`Module::Load\*(C'\fR.SH "BUG REPORTS".IX Header "BUG REPORTS"Please report bugs or other issues to <bug\-module\-load\-conditional@rt.cpan.org>..SH "AUTHOR".IX Header "AUTHOR"This module by Jos Boumans <kane@cpan.org>..SH "COPYRIGHT".IX Header "COPYRIGHT"This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -