Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Weird Term::Prompt behaviour

by gargle (Hermit)
on Sep 17, 2012 at 08:51 UTC ( #993991=perlquestion: print w/ replies, xml ) Need Help??
gargle has asked for the wisdom of the Perl Monks concerning the following question:

Now this is weird! I have the following code:
[gargle@vlds204 reporting]$ cat ./test.pl #!/usr/bin/perl use Modern::Perl; use Term::Prompt; my $mypass = prompt( 'x', "password:", '', '' ); say "alfa"; say "beta";
When I run this on stdout, I get this:
[gargle@vlds204 reporting]$ ./test.pl password: x alfa beta
When I pipe into a text file (or use redirection) I get this:
[gargle@vlds204 reporting]$ ./test.pl | tee test.txt x password: alfabeta[gargle@vlds204 reporting]$
I'm on perl v5.16.1, Term::Prompt is at 1.04, Modern::Perl is at 1.20120521. I'm not experiencing this behaviour on cygwin, on perl v5.14.2, Term::Prompt 1.04 and Modern::Perl 1.03. Can someone confirm this? What's going on?
--
if ( 1 ) { $postman->ring() for (1..2); }

Comment on Weird Term::Prompt behaviour
Select or Download Code
Re: Weird Term::Prompt behaviour
by Anonymous Monk on Sep 17, 2012 at 19:06 UTC

      Sorry, I forgot to mention that I did try $|=1 already. It doesn't work!

      [gargle@vlds204 reporting]$ cat test.pl #!/usr/bin/perl use Modern::Perl; use Term::Prompt; my $mypass = prompt( 'x', "password:", '', '' ); $|=1; say "alfa"; say "beta"; [gargle@vlds204 reporting]$ ./test.pl | tee test.txt x password: alfabeta[gargle@vlds204 reporting]$ ./test.pl password: x alfa beta [gargle@vlds204 reporting]$

      I'm starting to think my perl install is messed up. Are there any unit tests I can run?

      --
      if ( 1 ) { $postman->ring() for (1..2); }

        Sorry, I forgot to mention that I did try $|=1 already. It doesn't work!

        Doesn't work how? What is it you're expecting to happen that didn't happen?

        I'm starting to think my perl install is messed up.

        I doubt your install is messed up. You could try export  TERM=dumb   test.pl

        Are there any unit tests I can run?

        Sure, but they're not usually installed. You could verify your install with perlivp, but I doubt that'll help with this problem.

      What I find weird is that the '\n' are gone when I pipe or use redirection. So come these two runs don't give the same output, that's what I would like to know :
      [gargle@vlds204 reporting]$ ./test.pl password: x alfa beta
      [gargle@vlds204 reporting]$ ./test.pl | tee test.txt x password: alfabeta[gargle@vlds204 reporting]$ [gargle@vlds204 reporting]$
      --
      if ( 1 ) { $postman->ring() for (1..2); }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://993991]
Approved by McDarren
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2014-07-30 13:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (234 votes), past polls