Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to Teach artists Perl w/out Modules

by Sol-Invictus (Scribe)
on Jan 31, 2004 at 15:07 UTC ( #325552=note: print w/ replies, xml ) Need Help??


in reply to How to Teach artists Perl w/out Modules

Under Linux/Unix you can install CPAN or any other module in your user account and run it from there. If you don't have much diskspace you can just install the modules you need, though dependencies can make life awkward (see the trouble shooting section). Installing perl modules is fairly straight forward:

1. make a site_perl folder somewhere in your user account :

[SHELL PROMPT ]$ mkdir site_perl

2. set the environment variable PERL5LIB :

[SHELL PROMPT ]$ cd ~ # check for shell configuration files [SHELL PROMPT ]$ ls -al (for sh, bash, ksh, or zsh shells - example used: bash) [SHELL PROMPT ]$ pico ./.bashrc [PICO PROMPT ]$ export PERL5LIB=$HOME/path/to/my/site_perl (for csh or tcsh shells - example used tcsh) [SHELL PROMPT ]$ pico ./.cshrc [PICO PROMPT ]$ set PERL5LIB=/path/to/my/site_perl

you can check if it's set correctly by typing:

[SHELL PROMPT ]$ echo $PERL5LIB

This only affects the Environment variables of the shell, not the system, so you may have to logout and re-login in before the new path will become active. If the echo command still doesn't seem to print anything, or, if it prints something different from what you typed even after logging out and in, then the variable hasn't been set correctly. Repeat the last few steps again to set the new path.

3. FTP the module into your site_perl folder

[SHELL PROMPT ]$ cd /path/to/your/site_perl [SHELL PROMPT ]$ ftp ftp.CPAN.org/pub/CPAN login: anonymous ftp> get /path/to/yourmodule.tar.gz [space]/path/to/your/site_perl/yo +urmodule.tar.gz ftp> quit 221 Goodbye.

4. DECOMPRESS the file:

[SHELL PROMPT ]$ gzip -d yourmodule.tar.gz

5. UNPACK the file :

[SHELL PROMPT ]$ tar -xvf yourmodule.tar
6. BUILD the module (sometimes unnecessary):

[SHELL PROMPT ]$ perl Makefile.PL LIB=/path/to/my/site_perl \ INSTALLMAN1DIR=/path/to/my/man/man1 \ INSTALLMAN3DIR=/path/to/my/man/man3 [SHELL PROMPT ]$ make [SHELL PROMPT ]$ make test

7. INSTALL the module:

[SHELL PROMPT ]$ make install
8. Troubleshooting:

If you get errors about a file not being created:

i. create the path to the file as it was written in the error
ii. install again.

If the error says a module is missing - this is caused by dependancy, in other words the module you want uses another module:

i. FTP the missing module from ftp.CPAN.org into your site_perl folder as before
ii. go through the installation process as before.

After installation, in your scripts and cgis, insert the line (perl versions 5.002 and later):

use lib '/path/to/my/site_perl';
or for earlier perls (5.001 and before):

BEGIN { unshift(@INC, "/path/to/my/site_perl") }

so the perl interpreter will know to check your site_perl dir for modules.

Installing CPAN.pm

CPAN.pm was designed to free you out from the circular hell of dependancy. Follow the installation procedure as above, once installed and you've checked that the path to your site_perl folder is set correctly in the ENVIRONMENT variables you can start up the CPAN shell by typing:

[SHELL PROMPT ]$ perl -MCPAN -e shell

the first time you run it you'll be prompted for config info, in most cases the default values are fine (just press enter without writing anything), but you must make sure you set the following two correctly for either CPAN.pm, or any modules it installs, to work correctly:

cpan> cpan_home: /path/to/my/site_perl/ANY_NAME_YOU_WANT cpan> makepl_arg: LIB=/path/to/my/site_perl you can check these values in the CPAN shell at any time by typing: cpan> o conf
which outputs a listing of all the config variables* similar to this:

cpan> o conf CPAN::Config options and /Users/Sol-Invictus/site-perl/.cpan/CPAN/MyCo +nfig.pm: commit Commit changes to disk defaults Reload defaults from disk init Interactive setting of all options build_cache 10 build_dir /Users/Sol-Invictus/site-perl/.cpan/build cache_metadata 1 cpan_home /Users/Sol-Invictus/site-perl/.cpan dontload_hash ftp /usr/bin/ftp ftp_proxy getcwd cwd gzip /usr/bin/gzip histfile /Users/Sol-Invictus/site-perl/.cpan/histfile histsize 100 http_proxy inactivity_timeout 0 index_expire 1 inhibit_startup_message 0 keep_source_where /Users/Sol-Invictus/site-perl/.cpan/sources lynx make /usr/bin/make make_arg make_install_arg makepl_arg ncftp ncftpget no_proxy pager /usr/bin/less prerequisites_policy ask scan_cache atstart shell /bin/tcsh tar /usr/bin/tar term_is_latin 1 unzip /usr/bin/unzip urllist ftp://ftp.ayamura.org/pub/CPAN/ ftp://ftp.cpan.jp/CPAN/ ftp://ftp.dti.ad.jp/pub/lang/CPAN/ ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/ ftp://ftp.kddlabs.co.jp/CPAN/ ftp://ftp.meisei-u.ac.jp/pub/CPAN/ ftp://ftp.ring.gr.jp/pub/lang/perl/CPAN/ ftp://ftp.u-aizu.ac.jp/pub/CPAN ftp://mirror.nucba.ac.jp/mirror/Perl/ ftp://mirror.Mazic.org/pub/CPAN ftp://cpan.topend.com.au/pub/CPAN/ ftp://ftp.planetmirror.com/pub/CPAN/ ftp://mirror.aarnet.edu.au/pub/perl/CPAN/ ftp://cpan.in.freeos.com/pub/CPAN/ ftp://ftp.cbn.net.id/mirror/CPAN ftp://ftp.mweb.co.id/pub/languages/perl/CPAN/ wait_list wait://ls6-www.informatik.uni-dortmund.de:1404 wget

*note: the first 3 are commands

To run this config script again at any time type (in the CPAN shell):

cpan> o conf init

See the relevant MAN page or PODs for more information on how to set or unset these variables individually, either:

[SHELL PROMPT]$ perldoc CPAN

or:

[SHELL PROMPT]$ man CPAN

Once installed correctly, adding other modules to your site_perl becomes a breeze - just type:

[SHELL PROMPT ]$ perl -MCPAN -e shell cpan> install MODULE_YOU_WANT

and CPAN.pm does the rest (including installing any other fish hooked modules). Equally as useful, through CPAN you can check for newer releases of existing modules and automatically install them as they become available, much like a package management system. For a brief summary of CPAN.pm's commands use the CPAN shell's own internal help function:

cpan> ?


Comment on Re: How to Teach artists Perl w/out Modules
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://325552]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2014-09-02 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (21 votes), past polls