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.
|