Perl
From SkyWiki
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 ~/perl5libCreate ~/.cpan and ~/.cpan/CPAN directories: $ mkdir ~/.cpan $ mkdir ~/.cpan/CPANCreate 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). 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
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
Perl syntax
read a file line by line
open(IN, '<'.$ARGV[0]); foreach(<IN>) { chomp; print $_, "\n"; } close(IN);