On Thu, Feb 14, 2002 at 03:35:43PM +0000, Mark Fowler wrote:
> So..sensible default values, options to change to Makefile.PL for those 
> cases where you need to...and maybe then falling back to it being 
> interactive?

There's the entirely undocumented but really, really useful
ExtUtils::MakeMaker::prompt() function.

    use ExtUtils::MakeMaker;
    my $answer = prompt("Wanna buy a monkey?", "Yes");
    print "$answer\n";

which does All The Right Things:

$ perl ~/tmp/monkey.plx
Wanna buy a monkey? [Yes] No
No
$ perl ~/tmp/monkey.plx
Wanna buy a monkey? [Yes] 
Yes
$ perl ~/tmp/monkey.plx < /dev/null
Wanna buy a monkey? [Yes] Yes
Yes

That last one is showing prompt() automatically accepting the default
when STDIN is not a TTY (ditto for STDOUT).  It also honors
PERL_MM_USE_DEFAULT environment variable (which, oddly enough, is
documented).

Documenting it is in my TODO list.  Its safe to use.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
They had applied the blinders of steam-grilled hamburgers to my eyes.

Reply via email to