First, if you package a module Foo::Bar you should call your package libfoo-bar-perl.
In order to configure your Perl module you can use something like this :
At the top of debian/rules :
ifndef PERL PERL = /usr/bin/perl endif TMP =`pwd`/debian/tmp archlib =`$(PERL) -MConfig -e 'print $$Config{installarchlib}'` config =INSTALLDIRS=perl INSTALLMAN1DIR=$(TMP)/usr/share/man/man1 INSTALLMAN3DIR=$(TMP)/usr/share/man/man3 INSTALLPRIVLIB=$(TMP)/usr/lib/perl5 INSTALLARCHLIB=$(TMP)$(archlib)
If your module does also install binaries or scripts, you might want to add « INSTALLBIN=$(TMP)/usr/bin INSTALLSCRIPT=$(TMP)/usr/bin » to the $(config) variable given above.
And in the build target :
$(PERL) Makefile.PL $(config) $(MAKE) OPTIMIZE="-O2 -g -Wall"
And for installing the module in the tree :
$(MAKE) pure_install
Be sure to remove .packlist file installed automatically. You can add those lines for example :
find `pwd`/debian/tmp -type f -name .packlist | xargs -r rm -f -find `pwd`/debian/tmp -type d -empty | xargs -r rmdir -p --ignore-fail-on-non-empty
Note that the dh_perl script mentionned further in this document will do this for you.
As you may have noticed, we do not have hardcoded any specific Perl version in the build process but the package may have to depend on a specific Perl version (generally the version that has been used to build it). In order to never hardcode any Perl version, we'll try to use a substitution. Instead of writing "perl-5.005" or "perl5" in the control file we'll use "${perl:Depends}" and the build process will add a line "perl:Depends=what_is_needeed" to the substvars file.
In order to generate this substitution you can use dh_perl that is provided with debhelper. Or you can manage that yourself by adding the good lines in your rules file.
If you want to know the version of perl that you're currently using for the build you can use something like this :
version = `$(PERL) -e 'printf "%.3f", $$]'`
They must be installed in /usr/lib/perl5 and must depend on perl5.
They must be installed in /usr/lib/perl/$version/$cpu-$system and must depend on perl-$version. $cpu-$system is a GNU system type identifier, consisting of a cpu part and a system part, connected by a minus '-'. Examples are powerpc-linux or i386-gnu.
You may want to provide a threaded version of the module which will be installed in /usr/lib/perl5/$version/$cpu-$system-thread. You can provide the threaded module in the same package or in another package called libfoo-bar-perl-thread.
The binary modules must always be built with the latest Perl available in Debian. You can build the module for an older version of Perl but in that case you must call the module package accordingly by specifying the Perl version at the end of the package name (ie libfoo-bar-perl-5.004).