Perl

From SkyWiki

(Difference between revisions)
Jump to: navigation, search
(โ†’User-lokale Perl-Packages)
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 ~/perl5libCreate ~/.cpan and ~/.cpan/CPAN directories:
-
 
+
$ mkdir ~/.cpan      $ mkdir ~/.cpan/CPANCreate a Config.pm for the CPAN module with $CPAN::Config empty
-
$ 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.
-
$ 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  
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:
+
  Parameters for the 'perl Makefile.PL' command?
-
 
+
Typical frequently used settings:
-
  PREFIX=~/perl5lib/ LIB=~/perl5lib/lib INSTALLMAN1DIR=~/perl5lib/man1 INSTALLMAN3DIR=~/perl5lib/man3This will add the parameters for your user Makefile.
+
POLLUTE=1
-
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.
+
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).  
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=

Revision as of 09:46, 14 March 2009

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


Perl syntax

read a file line by line

  open(IN, '<'.$ARGV[0]);
  foreach(<IN>) {
    chomp;
    print $_, "\n";
  }
  close(IN);
Personal tools