in reply to Re^2: EU::MM (again)
in thread EU::MM (again)
Simple test, each exe appears to get its own historysub prompt ($;$) { ## no critic my($mess, $def) = @_; Carp::confess("prompt function called without an argument") unless defined $mess; my $isa_tty = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) + ; my $dispdef = defined $def ? "[$def] " : " "; $def = defined $def ? $def : ""; local $|=1; local $\; print "$mess $dispdef"; my $ans; if ($ENV{PERL_MM_USE_DEFAULT} || (!$isa_tty && eof STDIN)) { print "$def\n"; } else { $ans = <STDIN>; if( defined $ans ) { chomp $ans; } else { # user hit ctrl-D print "\n"; } } return (!defined $ans || $ans eq '') ? $def : $ans; }
perl -e"warn scalar readline(STDIN)" perl5.8.7 -e"warn scalar readline(STDIN)"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: EU::MM (again)
by BrowserUk (Patriarch) on Apr 15, 2009 at 11:27 UTC |