Perl
From SkyWiki
(→User-lokale Perl-Packages) |
m (→User-lokale Perl-Packages) |
||
Line 43: | Line 43: | ||
Finish the CPAN configuration by answering all other questions (ex.: http_proxy?http://your_proxy.yourdomain). | Finish the CPAN configuration by answering all other questions (ex.: http_proxy?http://your_proxy.yourdomain). | ||
- | or | + | |
+ | or run in CPAN: | ||
mkmyconfig | mkmyconfig | ||
Revision as of 10:52, 14 March 2009
Contents |
User-lokale Perl-Installation
./Configure -d -D prefix=$HOME make make install
-> in Perl-Scripts eintragen:
#!home/mike/bin/perl -w
in .profile, .bashrc o.ä.:
export PATH=$HOME/bin:$PATH
User-lokale Perl-Packages
Create a directory for the perl modules in your HOME
$ mkdir ~/perl5lib
Create ~/.cpan and ~/.cpan/CPAN directories:
$ mkdir ~/.cpan $ mkdir ~/.cpan/CPAN
Create a Config.pm for the CPAN module with $CPAN::Config empty
$ echo "\$CPAN::Config = {}"> ~/.cpan/CPAN/MyConfig.pmExecute again: $ perl -MCPAN -e shellThis time (if all goes well) it will prompt you for the empty fields in $CPAN::Config.
It is OK to accept the default values until it asks you for the parameters for the Makefile.pl
Parameters for the 'perl Makefile.PL' command? Typical frequently used settings: POLLUTE=1 increasing backwards compatibility LIB=~/perl
non-root users (please see manual for more hints)You should then answer with the following line:
PREFIX=~/perl5lib/ LIB=~/perl5lib/lib INSTALLMAN1DIR=~/perl5lib/man1 INSTALLMAN3DIR=~/perl5lib/man3
This will add the parameters for your user Makefile. This will enable installations of Modules (.pm) and compile code (.so) in ~/perl5lib/ (more accurately in a subdirectory named after the architecture of your machine). Files for the manual of the modules will also be installled in the specified directories.
Finish the CPAN configuration by answering all other questions (ex.: http_proxy?http://your_proxy.yourdomain).
or run in CPAN:
mkmyconfig
You will most probably also want to configure something like this:
o conf makepl_arg "LIB=~/myperl/lib \ INSTALLMAN1DIR=~/myperl/man/man1 \ INSTALLMAN3DIR=~/myperl/man/man3 \ INSTALLSCRIPT=~/myperl/bin \ INSTALLBIN=~/myperl/bin"
and then (oh joy) the equivalent command for Module::Build. That would be
o conf mbuildpl_arg "--lib=~/myperl/lib \ --installman1dir=~/myperl/man/man1 \ --installman3dir=~/myperl/man/man3 \ --installscript=~/myperl/bin \ --installbin=~/myperl/bin"
You can make this setting permanent like all o conf settings with o conf commit or by setting auto_commit beforehand.
Write the configuration to disk:
o conf commit
Set the environment variables for the perl lib path and the manpath. Using bash you should do something like
export PERL5LIB=${PERL5LIB}:~/perl5lib export MANPATH=~/perl5lib
You should add the environment variable settings to your profile file (in bash ~/.bash_profile)
Package-Installation
CPAN-Aufruf:
perl -MCPAN -eshell
oder einfach:
cpan
CPAN-Initialisierung:
install Bundle::libnet install Bundle::CPAN install MD5 install Bundle::LWP install HTML::Parser install HTML::Tree install Archive::Tar install GD install Mail::POP3Client install Mail::IMAPClient
Konfiguration
o conf init prerequisites_policy follow
o conf init build_requires_install_policy yes
o conf commit
Perl syntax
read a file line by line
open(IN, '<'.$ARGV[0]); foreach(<IN>) { chomp; print $_, "\n"; } close(IN);