qumsieh has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

What is the best way to package an application for release on CPAN? The application consists of a Perl script along with a bunch of modules and other files (icons and text files) needed by the script. The structure looks something like this:

ZooZ.pl README files ZooZ/ Bunch of .pm files icons/ Bunch of icon files
I know that a simple tarball of the whole thing is sufficient. But, is there a more elegant way of doing it?

Replies are listed 'Best First'.
Re: Package Application for CPAN
by Zaxo (Archbishop) on Sep 15, 2004 at 17:52 UTC
      Thanks. I have a healthy CPAN directory and know my way around h2xs and how to create a module package. But somehow I didn't think this was the "correct" way to go when packaging a complete application. Now that you made me think more about it, I think it will be the best solution.

      One question though, where will

      make install
      place the .pl file? I assume it'll go in @INC somewhere (or wherever PREFIX points to). Is this a good place for it to end up?

        where will make install place the .pl file?

        As always it depends. If you do nothing and have used h2xs to build your skeleton it will simply get dumped in the same location as your .pm files. To install a .pl script (say it is at DISTRO/bin/foo.pl in your distro) into a bin dir you modify the Makefile.PL like this:

        use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'Foo', 'VERSION_FROM' => 'Foo.pm', 'EXE_FILES' => ['bin/foo.pl'], # <--- Add list of .pl exe +files to install );

        The foo.pl script will now be installed in an architecture dependent bin dir. This will proabably allow the user to just type foo.pl as it will *probably* be in their path. On win32 a .bat file will also be automatically generated. You can control the install location with perl Makefile.PL PREFIX=blah This affects both .pm and exe_files. LIB controls compiled binary install location if you have C/XS code.

        cheers

        tachyon

        I believe the default is hardcoded into perl. It can be overridden by the user by specifying extra args to perl Makefile.PL, possibly as follows: perl Makefile.PL PREFIX=~. Refer to ExtUtils::MakeMaker.

        Update: A .pl file? oops, I don't know how .pl works, just modules.

        There are several CPAN modules which also contain 'executeables'.. They usually land in the same directory as the perl binary itself. Looking at the Makefile.PL for Prima (which was the first one I thought of), it does some complicated stuff to put its executeables somewhere useful.. Ah, and looking at DBI::Shell, it could have avoided all that by using:     EXE_FILES => [ "dbish$ext_pl" ], or similar, that's probably what you want.

        C.

      You'll probably get advice to use some newer builders
      Can you elaborate on this?
Re: Package Application for CPAN
by MrCromeDome (Deacon) on Sep 15, 2004 at 18:33 UTC
    Make sure to also check out tachyon's Simple Module Tutorial. I found it to be very, very helpful the first time I started putting modules together.

    Cheers!
    MrCromeDome

Re: Package Application for CPAN
by jacques (Priest) on Sep 15, 2004 at 18:19 UTC
    This is perfect for PAR, but it is not the standard (yet).
Re: Package Application for CPAN
by belg4mit (Prior) on Sep 15, 2004 at 20:55 UTC
    The CPAN script area only handles single (apparently ASCII) files, so I've resorted to the use of par (not PAR) -- the perl equivalent of shar.

    --
    I'm not belgian but I play one on TV.

Re: Package Application for CPAN
by borisz (Canon) on Sep 15, 2004 at 18:27 UTC
    Look at h2xs first, this get you started. Then get familar with the targets of the Makefile. (make manifest; make dist ... )
    Make sure thast you follow the usual installation procedure.
    perl Makefile.PL make make test make install
    Boris