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

📄 inc.pm

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PM
📖 第 1 页 / 共 2 页
字号:
package CPANPLUS::inc;=head1 NAMECPANPLUS::inc=head1 DESCRIPTIONOBSOLETE=cutsub original_perl5opt   { $ENV{PERL5OPT}    };sub original_perl5lib   { $ENV{PERL5LIB}    };sub original_inc        { @INC              };1;__END__use strict;use vars        qw[$DEBUG $VERSION $ENABLE_INC_HOOK %LIMIT $QUIET];use File::Spec  ();use Config      ();### 5.6.1. nags about require + bareword otherwise ###use lib ();$QUIET              = 0;$DEBUG              = 0;%LIMIT              = ();=pod=head1 NAMECPANPLUS::inc - runtime inclusion of privately bundled modules=head1 SYNOPSIS    ### set up CPANPLUS::inc to do it's thing ###    BEGIN { use CPANPLUS::inc };    ### enable debugging ###    use CPANPLUS::inc qw[DEBUG];=head1 DESCRIPTIONThis module enables the use of the bundled modules in theC<CPANPLUS/inc> directory of this package. These modules are bundledto make sure C<CPANPLUS> is able to bootstrap itself. It will do thefollowing things:=over 4=item Put a coderef at the beginning of C<@INC>This allows us to decide which module to load, and where to find it.For details on what we do, see the C<INTERESTING MODULES> section below.Also see the C<CAVEATS> section.=item Add the full path to the C<CPANPLUS/inc> directory to C<$ENV{PERL5LIB>.This allows us to find our bundled modules even if we spawn off a newprocess. Although it's not able to do the selective loading as thecoderef in C<@INC> could, it's a good fallback.=back=head1 METHODS=head2 CPANPLUS::inc->inc_path()Returns the full path to the C<CPANPLUS/inc> directory.=head2 CPANPLUS::inc->my_path()Returns the full path to be added to C<@INC> to loadC<CPANPLUS::inc> from.=head2 CPANPLUS::inc->installer_path()Returns the full path to the C<CPANPLUS/inc/installers> directory.=cut{   my $ext     = '.pm';    my $file    = (join '/', split '::', __PACKAGE__) . $ext;    ### os specific file path, if you're not on unix    my $osfile  = File::Spec->catfile( split('::', __PACKAGE__) ) . $ext;    ### this returns a unixy path, compensate if you're on non-unix    my $path    = File::Spec->rel2abs(                        File::Spec->catfile( split '/', $INC{$file} )                    );    ### don't forget to quotemeta; win32 paths are special    my $qm_osfile = quotemeta $osfile;    my $path_to_me          = $path; $path_to_me    =~ s/$qm_osfile$//i;    my $path_to_inc         = $path; $path_to_inc   =~ s/$ext$//i;    my $path_to_installers  = File::Spec->catdir( $path_to_inc, 'installers' );    sub inc_path        { return $path_to_inc  }    sub my_path         { return $path_to_me   }    sub installer_path  { return $path_to_installers }}=head2 CPANPLUS::inc->original_perl5libReturns the value of $ENV{PERL5LIB} the way it was when C<CPANPLUS::inc>got loaded.=head2 CPANPLUS::inc->original_perl5optReturns the value of $ENV{PERL5OPT} the way it was when C<CPANPLUS::inc>got loaded.=head2 CPANPLUS::inc->original_incReturns the value of @INC the way it was when C<CPANPLUS::inc> gotloaded.=head2 CPANPLUS::inc->limited_perl5opt(@modules);Returns a string you can assign to C<$ENV{PERL5OPT}> to have a limitedinclude facility from C<CPANPLUS::inc>. It will roughly look like:    -I/path/to/cpanplus/inc -MCPANPLUS::inc=module1,module2=cut{   my $org_opt = $ENV{PERL5OPT};    my $org_lib = $ENV{PERL5LIB};    my @org_inc = @INC;    sub original_perl5opt   { $org_opt || ''};    sub original_perl5lib   { $org_lib || ''};    sub original_inc        { @org_inc, __PACKAGE__->my_path };    sub limited_perl5opt    {        my $pkg = shift;        my $lim = join ',', @_ or return;        ### -Icp::inc -Mcp::inc=mod1,mod2,mod3        my $opt =   '-I' . __PACKAGE__->my_path . ' ' .                    '-M' . __PACKAGE__ . "=$lim";        $opt .=     $Config::Config{'path_sep'} .                    CPANPLUS::inc->original_perl5opt                if  CPANPLUS::inc->original_perl5opt;        return $opt;    }}=head2 CPANPLUS::inc->interesting_modules()Returns a hashref with modules we're interested in, and the minimumversion we need to find.It would looks something like this:    {   File::Fetch             => 0.06,        IPC::Cmd                => 0.22,        ....    }=cut{    my $map = {        ### used to have 0.80, but not it was never released by coral        ### 0.79 *should* be good enough for now... asked coral to         ### release 0.80 on 10/3/2006        'IPC::Run'                  => '0.79',         'File::Fetch'               => '0.07',        #'File::Spec'                => '0.82', # can't, need it ourselves...        'IPC::Cmd'                  => '0.24',        'Locale::Maketext::Simple'  => 0,        'Log::Message'              => 0,        'Module::Load'              => '0.10',        'Module::Load::Conditional' => '0.07',        'Params::Check'             => '0.22',        'Term::UI'                  => '0.05',        'Archive::Extract'          => '0.07',        'Archive::Tar'              => '1.23',        'IO::Zlib'                  => '1.04',        'Object::Accessor'          => '0.03',        'Module::CoreList'          => '1.97',        'Module::Pluggable'         => '2.4',        'Module::Loaded'            => 0,        #'Config::Auto'             => 0,   # not yet, not using it yet    };    sub interesting_modules { return $map; }}=head1 INTERESTING MODULESC<CPANPLUS::inc> doesn't even bother to try find and find a moduleit's not interested in. A list of I<interesting modules> can beobtained using the C<interesting_modules> method described above.Note that all subclassed modules of an C<interesting module> willalso be attempted to be loaded, but a version will not be checked.When it however does encounter a module it is interested in, it willdo the following things:=over 4=item Loop over your @INCAnd for every directory it finds there (skipping all non directories-- see the C<CAVEATS> section), see if the module requested can befound there.=item Check the version on every suitable module found in @INCAfter a list of modules has been gathered, the version of each of themis checked to find the one with the highest version, and return that asthe module to C<use>.This enables us to use a recent enough version from our own bundledmodules, but also to use a I<newer> module found in your path instead,if it is present. Thus having access to bugfixed versions as they arereleased.If for some reason no satisfactory version could be found, a warningwill be emitted. See the C<DEBUG> section for more details on how tofind out exactly what C<CPANPLUS::inc> is doing.=back=cut{   my $Loaded;    my %Cache;    ### returns the path to a certain module we found    sub path_to {        my $self    = shift;        my $mod     = shift or return;        ### find the directory        my $path    = $Cache{$mod}->[0][2] or return;        ### probe them explicitly for a special file, because the        ### dir we found the file in vs our own paths may point to the        ### same location, but might not pass an 'eq' test.        ### it's our inc-path        return __PACKAGE__->inc_path                if -e File::Spec->catfile( $path, '.inc' );        ### it's our installer path        return __PACKAGE__->installer_path                if -e File::Spec->catfile( $path, '.installers' );

⌨️ 快捷键说明

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