I actually prefer using MakeMaker (and h2xs) to perform this kind of task. MM allows you to specify perl programs to run at compile time as arguments to the WriteMakefile() routine:
WriteMakefile( NAME => 'Test::Bin', VERSION_FROM => 'lib/Test/Bin.pm', # finds $VERSION PREREQ_PM => {}, # e.g., Module::Name => 1.1 PL_FILES => { 'bin/test.PL $(INSTALLSITELIB) $(INSTALLSITEARCH)' => 'lib/Test/Bin.pm' }, );
The PL_FILES attribute allows you to specify the .PL files and which files they should modify. I add the $(INSTALLSITELIB) $(INSTALLSITEARCH) as arguments so the perl program will receive those macros from the makefile. Then, for example, I would transform a package like the following:
package Test::Bin; use 5.008002; use strict; use warnings; use '###LIBPREFIX###'; # Use some easily matchable phrases use '###ARCPREFIX###'; 1; __END__
by using this .PL file:
#!/usr/bin/perl -w -pi~ # Use command line options to read and write file(s). use strict; our ($lib, $arc); BEGIN { $lib = shift @ARGV; # Shift off the arguments so they are $arc = shift @ARGV; # not processed as files } s/\Q###LIBPREFIX###\E/$lib/; # perform substitutions s/\Q###ARCPREFIX###\E/$arc/; 1; __END__
The end result is at least similar to what you are looking for:
package Test::Bin; use 5.008002; use strict; use warnings; use '/home/orderthruchaos/local/lib/perl5/site_perl/5.8.2'; use '/home/orderthruchaos/local/lib/perl5/site_perl/5.8.2/i686-linux'; require Exporter; our $VERSION = '0.01'; 1; __END__
Hope this helps.

In reply to Re: Variable to point to library? by orderthruchaos
in thread Variable to point to library? by bradcathey

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.