cpan.html

来自「perl教程」· HTML 代码 · 共 1,396 行 · 第 1/4 页

HTML
1,396 行
字号
<dt><strong><a name="item_o_conf__3clist_option_3e__5bunshift_7cpush_7csplic"><code>o conf &lt;list option&gt; [unshift|push|splice] &lt;list&gt;</code></a></strong>

<dd>
<p>works like the corresponding perl commands.</p>
</dd>
</li>
</dl>
<p>
</p>
<h2><a name="note_on_urllist_parameter_s_format">Note on urllist parameter's format</a></h2>
<p>urllist parameters are URLs according to RFC 1738. We do a little
guessing if your URL is not compliant, but if you have problems with
file URLs, please try the correct format. Either:</p>
<pre>
    <a href="file://localhost/whatever/ftp/pub/CPAN/">file://localhost/whatever/ftp/pub/CPAN/</a></pre>
<p>or</p>
<pre>
    <a href="file:///home/ftp/pub/CPAN/">file:///home/ftp/pub/CPAN/</a></pre>
<p>
</p>
<h2><a name="urllist_parameter_has_cdrom_support">urllist parameter has CD-ROM support</a></h2>
<p>The <code>urllist</code> parameter of the configuration table contains a list of
URLs that are to be used for downloading. If the list contains any
<code>file</code> URLs, CPAN always tries to get files from there first. This
feature is disabled for index files. So the recommendation for the
owner of a CD-ROM with CPAN contents is: include your local, possibly
outdated CD-ROM as a <code>file</code> URL at the end of urllist, e.g.</p>
<pre>
  o conf urllist push <a href="file://localhost/CDROM/CPAN">file://localhost/CDROM/CPAN</a></pre>
<p>CPAN.pm will then fetch the index files from one of the CPAN sites
that come at the beginning of urllist. It will later check for each
module if there is a local copy of the most recent version.</p>
<p>Another peculiarity of urllist is that the site that we could
successfully fetch the last file from automatically gets a preference
token and is tried as the first site for the next request. So if you
add a new site at runtime it may happen that the previously preferred
site will be tried another time. This means that if you want to disallow
a site for the next transfer, it must be explicitly removed from
urllist.</p>
<p>
</p>
<hr />
<h1><a name="security">SECURITY</a></h1>
<p>There's no strong security layer in CPAN.pm. CPAN.pm helps you to
install foreign, unmasked, unsigned code on your machine. We compare
to a checksum that comes from the net just as the distribution file
itself. If somebody has managed to tamper with the distribution file,
they may have as well tampered with the CHECKSUMS file. Future
development will go towards strong authentication.</p>
<p>
</p>
<hr />
<h1><a name="export">EXPORT</a></h1>
<p>Most functions in package CPAN are exported per default. The reason
for this is that the primary use is intended for the cpan shell or for
one-liners.</p>
<p>
</p>
<hr />
<h1><a name="populate_an_installation_with_lots_of_modules">POPULATE AN INSTALLATION WITH LOTS OF MODULES</a></h1>
<p>Populating a freshly installed perl with my favorite modules is pretty
easy if you maintain a private bundle definition file. To get a useful
blueprint of a bundle definition file, the command autobundle can be used
on the CPAN shell command line. This command writes a bundle definition
file for all modules that are installed for the currently running perl
interpreter. It's recommended to run this command only once and from then
on maintain the file manually under a private name, say
Bundle/my_bundle.pm. With a clever bundle file you can then simply say</p>
<pre>
    cpan&gt; install Bundle::my_bundle</pre>
<p>then answer a few questions and then go out for a coffee.</p>
<p>Maintaining a bundle definition file means keeping track of two
things: dependencies and interactivity. CPAN.pm sometimes fails on
calculating dependencies because not all modules define all MakeMaker
attributes correctly, so a bundle definition file should specify
prerequisites as early as possible. On the other hand, it's a bit
annoying that many distributions need some interactive configuring. So
what I try to accomplish in my private bundle file is to have the
packages that need to be configured early in the file and the gentle
ones later, so I can go out after a few minutes and leave CPAN.pm
untended.</p>
<p>
</p>
<hr />
<h1><a name="working_with_cpan_pm_behind_firewalls">WORKING WITH CPAN.pm BEHIND FIREWALLS</a></h1>
<p>Thanks to Graham Barr for contributing the following paragraphs about
the interaction between perl, and various firewall configurations. For
further informations on firewalls, it is recommended to consult the
documentation that comes with the ncftp program. If you are unable to
go through the firewall with a simple Perl setup, it is very likely
that you can configure ncftp so that it works for your firewall.</p>
<p>
</p>
<h2><a name="three_basic_types_of_firewalls">Three basic types of firewalls</a></h2>
<p>Firewalls can be categorized into three basic types.</p>
<dl>
<dt><strong><a name="item_http_firewall">http firewall</a></strong>

<dd>
<p>This is where the firewall machine runs a web server and to access the
outside world you must do it via the web server. If you set environment
variables like http_proxy or ftp_proxy to a values beginning with http://
or in your web browser you have to set proxy information then you know
you are running an http firewall.</p>
</dd>
<dd>
<p>To access servers outside these types of firewalls with perl (even for
ftp) you will need to use LWP.</p>
</dd>
</li>
<dt><strong><a name="item_ftp_firewall">ftp firewall</a></strong>

<dd>
<p>This where the firewall machine runs an ftp server. This kind of
firewall will only let you access ftp servers outside the firewall.
This is usually done by connecting to the firewall with ftp, then
entering a username like <a href="mailto:"user@outside.host.com"">"user@outside.host.com"</a></p>
</dd>
<dd>
<p>To access servers outside these type of firewalls with perl you
will need to use Net::FTP.</p>
</dd>
</li>
<dt><strong><a name="item_one_way_visibility">One way visibility</a></strong>

<dd>
<p>I say one way visibility as these firewalls try to make themselves look
invisible to the users inside the firewall. An FTP data connection is
normally created by sending the remote server your IP address and then
listening for the connection. But the remote server will not be able to
connect to you because of the firewall. So for these types of firewall
FTP connections need to be done in a passive mode.</p>
</dd>
<dd>
<p>There are two that I can think off.</p>
</dd>
<dl>
<dt><strong><a name="item_socks">SOCKS</a></strong>

<dd>
<p>If you are using a SOCKS firewall you will need to compile perl and link
it with the SOCKS library, this is what is normally called a 'socksified'
perl. With this executable you will be able to connect to servers outside
the firewall as if it is not there.</p>
</dd>
</li>
<dt><strong><a name="item_ip_masquerade">IP Masquerade</a></strong>

<dd>
<p>This is the firewall implemented in the Linux kernel, it allows you to
hide a complete network behind one IP address. With this firewall no
special compiling is needed as you can access hosts directly.</p>
</dd>
<dd>
<p>For accessing ftp servers behind such firewalls you may need to set
the environment variable <code>FTP_PASSIVE</code> to a true value, e.g.</p>
</dd>
<dd>
<pre>
    env FTP_PASSIVE=1 perl -MCPAN -eshell</pre>
</dd>
<dd>
<p>or</p>
</dd>
<dd>
<pre>
    <span class="variable">perl</span> <span class="operator">-</span><span class="variable">MCPAN</span> <span class="keyword">-e</span> <span class="string">'$ENV{FTP_PASSIVE} = 1; shell'</span>
</pre>
</dd>
</li>
</dl>
</dl>
<p>
</p>
<h2><a name="configuring_lynx_or_ncftp_for_going_through_a_firewall">Configuring lynx or ncftp for going through a firewall</a></h2>
<p>If you can go through your firewall with e.g. lynx, presumably with a
command such as</p>
<pre>
    /usr/local/bin/lynx -pscott:tiger</pre>
<p>then you would configure CPAN.pm with the command</p>
<pre>
    o conf lynx &quot;/usr/local/bin/lynx -pscott:tiger&quot;</pre>
<p>That's all. Similarly for ncftp or ftp, you would configure something
like</p>
<pre>
    o conf ncftp &quot;/usr/bin/ncftp -f /home/scott/ncftplogin.cfg&quot;</pre>
<p>Your mileage may vary...</p>
<p>
</p>
<hr />
<h1><a name="faq">FAQ</a></h1>
<ol>
<li><strong><a name="item__29">)</a></strong>

<p>I installed a new version of module X but CPAN keeps saying,
I have the old version installed</p>
<p>Most probably you <strong>do</strong> have the old version installed. This can
happen if a module installs itself into a different directory in the
@INC path than it was previously installed. This is not really a
CPAN.pm problem, you would have the same problem when installing the
module manually. The easiest way to prevent this behaviour is to add
the argument <code>UNINST=1</code> to the <code>make install</code> call, and that is why
many people add this argument permanently by configuring</p>
<pre>
  o conf make_install_arg UNINST=1</pre>
</li>
<li><strong>)</strong>

<p>So why is UNINST=1 not the default?</p>
<p>Because there are people who have their precise expectations about who
may install where in the @INC path and who uses which @INC array. In
fine tuned environments <code>UNINST=1</code> can cause damage.</p>
</li>
<li><strong>)</strong>

<p>I want to clean up my mess, and install a new perl along with
all modules I have. How do I go about it?</p>
<p>Run the autobundle command for your old perl and optionally rename the
resulting bundle file (e.g. Bundle/mybundle.pm), install the new perl
with the Configure option prefix, e.g.</p>
<pre>
    ./Configure -Dprefix=/usr/local/perl-5.6.78.9</pre>
<p>Install the bundle file you produced in the first step with something like</p>
<pre>
    cpan&gt; install Bundle::mybundle</pre>
<p>and you're done.</p>
</li>
<li><strong>)</strong>

<p>When I install bundles or multiple modules with one command
there is too much output to keep track of.</p>
<p>You may want to configure something like</p>
<pre>
  o conf make_arg &quot;| tee -ai /root/.cpan/logs/make.out&quot;
  o conf make_install_arg &quot;| tee -ai /root/.cpan/logs/make_install.out&quot;</pre>
<p>so that STDOUT is captured in a file for later inspection.</p>
</li>
<li><strong>)</strong>

<p>I am not root, how can I install a module in a personal directory?</p>
<p>You will most probably like something like this:</p>
<pre>
  o conf makepl_arg &quot;LIB=~/myperl/lib \
                    INSTALLMAN1DIR=~/myperl/man/man1 \
                    INSTALLMAN3DIR=~/myperl/man/man3&quot;
  install Sybase::Sybperl</pre>
<p>You can make this setting permanent like all <code>o conf</code> settings with
<code>o conf commit</code>.</p>
<p>You will have to add ~/myperl/man to the MANPATH environment variable
and also tell your perl programs to look into ~/myperl/lib, e.g. by
including</p>
<pre>
  <span class="keyword">use</span> <span class="variable">lib</span> <span class="string">"$ENV{HOME}/myperl/lib"</span><span class="operator">;</span>
</pre>
<p>or setting the PERL5LIB environment variable.</p>
<p>Another thing you should bear in mind is that the UNINST parameter
should never be set if you are not root.</p>
</li>
<li><strong>)</strong>

<p>How to get a package, unwrap it, and make a change before building it?</p>
<pre>
  look Sybase::Sybperl</pre>
</li>
<li><strong>)</strong>

<p>I installed a Bundle and had a couple of fails. When I
retried, everything resolved nicely. Can this be fixed to work
on first try?</p>
<p>The reason for this is that CPAN does not know the dependencies of all
modules when it starts out. To decide about the additional items to
install, it just uses data found in the generated Makefile. An
undetected missing piece breaks the process. But it may well be that
your Bundle installs some prerequisite later than some depending item
and thus your second try is able to resolve everything. Please note,
CPAN.pm does not know the dependency tree in advance and cannot sort
the queue of things to install in a topologically correct order. It
resolves perfectly well IFF all modules declare the prerequisites
correctly with the PREREQ_PM attribute to MakeMaker. For bundles which
fail and you need to install often, it is recommended sort the Bundle
definition file manually. It is planned to improve the metadata
situation for dependencies on CPAN in general, but this will still
take some time.</p>
</li>
<li><strong>)</strong>

<p>In our intranet we have many modules for internal use. How
can I integrate these modules with CPAN.pm but without uploading
the modules to CPAN?</p>
<p>Have a look at the CPAN::Site module.</p>
</li>
<li><strong>)</strong>

<p>When I run CPAN's shell, I get error msg about line 1 to 4,
setting meta input/output via the /etc/inputrc file.</p>
<p>Some versions of readline are picky about capitalization in the
/etc/inputrc file and specifically RedHat 6.2 comes with a
/etc/inputrc that contains the word <code>on</code> in lowercase. Change the
occurrences of <code>on</code> to <code>On</code> and the bug should disappear.</p>
</li>
<li><strong>)</strong>

<p>Some authors have strange characters in their names.</p>
<p>Internally CPAN.pm uses the UTF-8 charset. If your terminal is
expecting ISO-8859-1 charset, a converter can be activated by setting
term_is_latin to a true value in your config file. One way of doing so
would be</p>
<pre>
    <span class="variable">cpan</span><span class="operator">&gt;</span> <span class="operator">!</span> <span class="variable">$CPAN::Config</span><span class="operator">-&gt;</span><span class="operator">{</span><span class="string">term_is_latin</span><span class="operator">}</span><span class="operator">=</span><span class="number">1</span>
</pre>
<p>Extended support for converters will be made available as soon as perl
becomes stable with regard to charset issues.</p>
</li>
</ol>
<p>
</p>
<hr />
<h1><a name="bugs">BUGS</a></h1>
<p>We should give coverage for <strong>all</strong> of the CPAN and not just the PAUSE
part, right? In this discussion CPAN and PAUSE have become equal --
but they are not. PAUSE is authors/, modules/ and scripts/. CPAN is
PAUSE plus the clpa/, doc/, misc/, ports/, and src/.</p>
<p>Future development should be directed towards a better integration of
the other parts.</p>
<p>If a Makefile.PL requires special customization of libraries, prompts
the user for special input, etc. then you may find CPAN is not able to
build the distribution. In that case, you should attempt the
traditional method of building a Perl module package from a shell.</p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Andreas Koenig &lt;<a href="mailto:andreas.koenig@anima.de">andreas.koenig@anima.de</a>&gt;</p>
<p>
</p>
<hr />
<h1><a name="translations">TRANSLATIONS</a></h1>
<p>Kawai,Takanori provides a Japanese translation of this manpage at
<a href="http://member.nifty.ne.jp/hippo2000/perltips/CPAN.htm">http://member.nifty.ne.jp/hippo2000/perltips/CPAN.htm</a></p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p>perl(1), CPAN::Nox(3)</p>

</body>

</html>

⌨️ 快捷键说明

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