I wanted to package up a module as a PAR dist, but couldn't figure out how to get either Build.PL or the PAR tools to include extra files from my par/ dir, and possibly my tests, into blib/ or the PAR::Dist target.

So I cooked up this hackaround. It may be useful for people, but I'm posting this as a SoPW and not a Snippet because somehow I feel I'm doing something wrong. Certainly, this only Works For MeTM because the module I'm packaging is pure Perl and doesn't need a blib/; YMMV and if you know the Right Thing to do here, please let me know.

In any case, here it is. It just makes a PAR from everything in your MANIFEST, and names it DIST-VER.par. Usage:

./Build.PL && ./Build pardist

In your Build.PL, instead of

my $build = new Module::Builder

Put this:

my $class = Module::Build->subclass ( class => 'My::Builder', code => q# sub make_parfile { my ($self, $file) = @_; $file =~ s/(?<!\.par)$/.par/; print "Creating $file\n"; require Archive::Zip; my $zip = Archive::Zip->new(); $zip->addFile($_) for keys %{ $self->_read_manifest('MANIFEST') +}; die 'write error' unless $zip->writeToFileNamed( $file ) == Arch +ive::Zip->AZ_OK; } sub ACTION_pardist { my($self) = @_; $self->make_parfile(join "-", $self->dist_name, $self->dist_vers +ion); } #, ); my $build = $class->new # The rest is the same.

In reply to PAR target for Module::Build by gaal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.