A couple comments here. First, you're free to get whatever input you want from the user before constructing the Module::Build object. Put that input in a hash and add it to the arguments to new(). If you're really set on using prompt() from Module::Build, there's nothing in that function that requires an object so you should be able to just call it as a class method. See below for an example (on the command line).

$ perl -MModule::Build -e 'Module::Build->prompt("are you there","Y")' are you there [Y] Y

That means that something like this should work:

$user_install_base = Module::Build->prompt("Where to install?","/usr +/local"); Module::Build->new( ... install_base => $user_install_base, ... );

Second, I'm not entirely sure why you feel you need to prompt a user for this as part of your Build.PL or if that's in fact the wisest thing to do if you're building a module for general use. (If you're using this for another purpose, then it may not matter.) For one thing, Module::Build already has a fairly well defined set of default installation locations. Also, it has a very easy method to allow users to override that location by passing parameters on the command line either when creating the Build script with Build.PL or when using the Build script. E.g.:

$ perl Build.PL install_base=/home/david or $ Build install install_base=/home/david

Simply documenting that in your README or other documentation should be sufficient to guide your users for custom locations. If you really want to be picky, your Build.PL could simply check the supplied arguments for a valid "install_base" command line argument to be sure a user supplied that or else quit with an error requiring them to add that. (That will play havoc with CPAN installations, so I'd only use that for some custom purpose.)

Best of luck!

-xdg

Code posted by xdg on PerlMonks is public domain. It has no warranties, express or implied. Posted code may not have been tested. Use at your own risk.


In reply to Re: Setting values in Module::Build by xdg
in thread Setting values in Module::Build by EvdB

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.