Perl

From SkyWiki

(Difference between revisions)
Jump to: navigation, search
Current revision (12:31, 14 March 2009) (view source)
(WWW::Mechanize)
 
(11 intermediate revisions not shown.)
Line 22: Line 22:
Create a directory for the perl modules in your HOME
Create a directory for the perl modules in your HOME
-
$ mkdir ~/perl5libCreate ~/.cpan and ~/.cpan/CPAN directories:
+
$ 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.
-
$ mkdir ~/.cpan      $ mkdir ~/.cpan/CPANCreate a Config.pm for the CPAN module with $CPAN::Config empty
+
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
-
$ echo "\$CPAN::Config = {}"> ~/.cpan/CPAN/MyConfig.pmExecute again:
+
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.
-
$ perl -MCPAN -e shellThis time (if all goes well) it will prompt you for the empty fields in $CPAN::Config.
+
Finish the CPAN configuration by answering all other questions (ex.: http_proxy?http://your_proxy.yourdomain).
-
It is OK to accept the default values until it asks you for the parameters for the Makefile.pl
+
or run in CPAN:
-
  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:
+
  mkmyconfig
-
PREFIX=~/perl5lib/ LIB=~/perl5lib/lib INSTALLMAN1DIR=~/perl5lib/man1 INSTALLMAN3DIR=~/perl5lib/man3This will add the parameters for your user Makefile.
+
You will most probably also want to configure something like this:
-
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.
+
  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
-
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
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=~/perl5libYou should add the environment variable settings to your profile file (in bash ~/.bash_profile)
+
  export PERL5LIB=${PERL5LIB}:~/perl5lib
 +
export MANPATH=~/perl5lib
 +
You should add the environment variable settings to your profile file (in bash ~/.bash_profile)
=Package-Installation=
=Package-Installation=
Line 48: Line 75:
CPAN-Aufruf:
CPAN-Aufruf:
  perl -MCPAN -eshell
  perl -MCPAN -eshell
 +
oder einfach:
 +
cpan
CPAN-Initialisierung:
CPAN-Initialisierung:
Line 59: Line 88:
install Archive::Tar
install Archive::Tar
install GD
install GD
 +
install Mail::POP3Client
 +
install Mail::IMAPClient
 +
install MIME::Words
 +
install WWW::Mechanize
</pre>
</pre>
 +
 +
==Konfiguration==
 +
 +
[http://search.cpan.org/~andk/CPAN-1.9304/lib/CPAN.pm CPAN-Dokumenatation]
 +
 +
o conf init prerequisites_policy
 +
follow
 +
 +
o conf init build_requires_install_policy
 +
yes
 +
 +
o conf commit
== [http://www.perl.org/ Perl] syntax ==
== [http://www.perl.org/ Perl] syntax ==

Current revision

Contents

User-lokale Perl-Installation

locally install Perl:

./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

user CPAN installation

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
install MIME::Words
install WWW::Mechanize


Konfiguration

CPAN-Dokumenatation

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);
Personal tools