Differences between revisions 16 and 17
Revision 16 as of 2021-03-28 17:59:22
Size: 5988
Editor: ?MartinSamuelsson
Comment:
Revision 17 as of 2021-03-29 03:12:07
Size: 5815
Editor: PaulWise
Comment: minor cleanups
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## Auto-converted by kwiki2moinmoin v2005-10-07
Line 3: Line 2:
Perl is used quite extensively in Debian. Not only are some core functions written in Perl, but there are over 700 packages in unstable that have perl in their name (Mar 2004).
Line 5: Line 3:
http://packages.debian.org/stable/perl/perl Perl is used quite extensively in Debian. Not only are some core functions written in Perl, but there many packages in Debian that have perl in their name.

https://packages.debian.org/stable/perl/perl
Line 10: Line 10:
http://www.cpan.org/
https://www.cpan.org/
Line 19: Line 20:
Enter DebPkg:dh-make-perl . This debhelper program handles the Debianizing process of Perl modules from CPAN.
Enter DebPkg:dh-make-perl. This debhelper program handles the Debianizing process of Perl modules from CPAN.
Line 21: Line 24:
 dh-make-perl --build --cpan Perl::Tidy dh-make-perl --build --cpan Perl::Tidy
Line 27: Line 30:
Line 38: Line 42:
Line 40: Line 45:
The [[http://search.cpan.org/~jhi/perl-5.8.0/lib/CPAN.pm|CPAN.pm documentation]] has '''this advice for using CPAN into ~/perl:''' The [[https://metacpan.org/pod/CPAN|CPAN.pm documentation]] has '''this advice for using CPAN into ~/perl:'''
Line 47: Line 52:
Line 57: Line 63:
Line 58: Line 65:
  use lib "$ENV{HOME}/myperl/lib"; use lib "$ENV{HOME}/myperl/lib";
Line 66: Line 73:
----
Line 68: Line 74:
/What about installing into usr/local?/
===
What about installing into usr/local? ===
Line 72: Line 79:
/What if you want to install an updated version of perl in usr/local for experimental work but keep the Debian/Release version in usr?/ This setup may not work out well with the Debian Perl package for Sarge since it has its own ideas about Perl stuff in /usr/local. === What if you want to install an updated version of perl in usr/local for experimental work but keep the Debian/Release version in usr? ===
Line 74: Line 81:
---- This setup may not work out well with the Debian Perl package for Sarge since it has its own ideas about Perl stuff in /usr/local.
Line 76: Line 84:
Line 80: Line 89:
Program reads a config file in the same directory using open(){{{
 #! /usr/bin/perl
 BEGIN {
   open(CONF,"libconf");
   my $l = <CONF>;
   close(CONF);
   chomp($l); #remove trailing LF
   require lib;
   lib->import($l);
  }
}}}
Program reads a config file in the same directory using open()
Line 92: Line 92:
 -- config --
 /my/libs/path
#! /usr/bin/perl
BEGIN {
  open(CONF,"libconf");
  my $l = <CONF>;
  close(CONF);
  chomp($l); #remove trailing LF
  require lib;
  lib->import($l);
}
Line 96: Line 103:
Program requires a local config script.{{{
 #! /usr/bin/perl
 BEGIN {
    require ".uselib.pl";
 }
}}}
Line 103: Line 104:
 -- .uselib.pl --
 # Local setting overrides for program
 use lib qw( /my/libs/path );
 # You can define a uselib package and some
 # variables to export here
 1;
-- config --
/my/libs/path
Line 111: Line 108:
Program requires a local config script.
Line 112: Line 110:
---- {{{
#! /usr/bin/perl
BEGIN {
   require ".uselib.pl";
}
}}}

{{{
-- .uselib.pl --
# Local setting overrides for program
use lib qw( /my/libs/path );
# You can define a uselib package and some
# variables to export here
1;
}}}
Line 114: Line 127:
Line 116: Line 130:
== Perl package Spotlight ==
Line 117: Line 132:
----
== Perl package Spotlight ==
Line 120: Line 133:
Line 123: Line 137:
Line 124: Line 139:

----
== Current known issues ==
Please share known issues and experiences here.

Debian Perl FAQ

Perl is used quite extensively in Debian. Not only are some core functions written in Perl, but there many packages in Debian that have perl in their name.

https://packages.debian.org/stable/perl/perl


Dpkg, Perl and CPAN

https://www.cpan.org/

Searching the Comprehensive Perl Archive Network (CPAN) can be as much of a candy-store experience as searching the Debian packages for software. CPAN provides a way for Perl developers to distribute their work in an organized fashion that includes user feedback.

Before you take the plunge and run perl -MCPAN -e shell, consider what the effects of your actions will be on your nice dpkg system. Installing directly from CPAN into usr/lib/perl will mean you are mixing dpkg managed files with CPAN managed files, and most likely the dependencies of dpkg will never be the same.

The way Debian's Perl package in Sarge is configured CPAN works just fine. The Debian Perl package defines siteprefix as /usr/local and sitelib as /usr/local/share/perl/5.8.4 and sitearch as /usr/local/lib/perl/5.8.4. Because of this if you use CPAN and take the default settings your extra stuff from CPAN goes into the right places in /usr/local.

From CPAN distribution to Debian package: dh-make-perl

Enter dh-make-perl. This debhelper program handles the Debianizing process of Perl modules from CPAN.

dh-make-perl --build --cpan Perl::Tidy

This will make a Debian package in the current directory for installing the Perl::Tidy module. Installing the package will update the dpkg database and keep your package dependencies in order:

As root, run something like:

sudo dpkg -i libperl-tidy_xxxx.deb

You will still need to use discretion when choosing packages to build and install. For example, while you could use dh-make-perl to build CGI::Kwiki, a DebianDeveloper is already maintaining this package ( Kwiki ) and is most likely doing a better job than this automated build will do. Plus the bug tracking system (BTS) is in place.

If the module isn't available for your release or isn't available at all, dh-make-perl away.

Feel free to see https://perl-team.pages.debian.net/ for best practices on how to debianize perl modules.

per-user Perl modules

If you don't have system install privileges, or if you don't need to make site-wide installs of the perl modules, you could use CPAN and install into ~/perl.

The CPAN.pm documentation has this advice for using CPAN into ~/perl:

When the CPAN module is installed, a site wide configuration file is created as CPAN/Config.pm. The default values defined there can be overridden in another configuration file: CPAN/!?MyConfig.pm. You can store this file in $HOME/.cpan/CPAN/!?MyConfig.pm if you want, because $HOME/.cpan is added to the search path of the CPAN module before the use() or require() statements.

5) I am not root, how can I install a module in a personal directory?

You will most probably like something like this:

  o conf makepl_arg "LIB=~/myperl/lib \
                    ["INSTALLMAN1DIR"]=~/myperl/man/man1 \
                    ["INSTALLMAN3DIR"]=~/myperl/man/man3"
  install Sybase::Sybperl

You can make this setting permanent like all o conf settings with o conf commit.

You will have to add ~/myperl/man to the MANPATH environment variable and also tell your perl programs to look into ~/myperl/lib, e.g. by including

use lib "$ENV{HOME}/myperl/lib";

or setting the ?PERL5LIB environment variable.

Another thing you should bear in mind is that the UNINST parameter should never be set if you are not root.

Running a different version of Perl in usr/local

What about installing into usr/local?

This should work similarly to the tips on running out of $HOME, with the advantage of possibly already having /usr/local/lib/perl/<version> in your @INC. Look for /usr/lib/*/Config.pm to see how your /usr/bin/perl is configured.

What if you want to install an updated version of perl in usr/local for experimental work but keep the Debian/Release version in usr?

This setup may not work out well with the Debian Perl package for Sarge since it has its own ideas about Perl stuff in /usr/local.

How can I make my @INC path more dynamic

If you have your Perl module (.pm) files in the same directory or same relative directory from your Perl program files (aka scripts ) then ?FindBin may be the package for you.

If you want to not force a directory structure depenancy on your program and libs but you aren't using /usr/lib/perl for your libs, try these tricks:

Program reads a config file in the same directory using open()

BEGIN {
  open(CONF,"libconf");
  my $l = <CONF>;
  close(CONF);
  chomp($l); #remove trailing LF
  require lib;
  lib->import($l);
}

-- config --
/my/libs/path

Program requires a local config script.

BEGIN {
   require ".uselib.pl";
}

-- .uselib.pl --
# Local setting overrides for program
use lib qw( /my/libs/path );
# You can define a uselib package and some
# variables to export here
1;

Communicating about Perl on Debian

Please see Debian Perl Group for ways of interacting about anything perl in Debian.

Perl package Spotlight

SpamAssassin

This impressively effective email scoring tool uses Perl's regexp power to its fullest. It also allows other programs to be plugged into it, increasing its flexibility and power. SpamAssassin

Kwiki (of course)

A Quickie Wiki that's not too Tricky.