Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Term::UI on Win32

by derimac (Novice)
on Mar 17, 2012 at 07:42 UTC ( [id://960136]=note: print w/replies, xml ) Need Help??


in reply to Re: Term::UI on Win32
in thread Term::UI on Win32

Hello marmot
I found the problem. my script creates 8 different Term::ReadLine objects in different sub routines. The term object is created within each sub routine. It looks as you can only create a single object of Term::ReadLine in a single Perl script.
If you try to create a second one then you get the message. If I use for these different input methods just a single object it works without the message on Windows. As I have said multiple Term objects are working fine on Linux and MacOSX but not on Windows.
Do you have any idea why this is the reason?


use Term::UI; use Term::ReadLine; my $term = Term::ReadLine->new('lang'); my $reply = $term->get_reply( prompt => 'What is your default prog. la +ng?', default => 'Perl'); my $term2 = Term::ReadLine->new('OS'); $reply = $term2->get_reply( prompt => 'What is your OS?', default => ' +MacOS');

Any ideas?
Thanks Andreas

Replies are listed 'Best First'.
Re^3: Term::UI on Win32
by bingos (Vicar) on Mar 19, 2012 at 09:58 UTC

    You can only create a single object of Term::ReadLine if the Term::ReadLine::Perl 'personality' is being used.

    Behold

    C:\tmp>perl foo.pl What is your default prog. lang? [Perl]: What is your OS? [MacOS]: C:\tmp>perl -I Term-ReadLine-Perl-1.0303\blib\lib foo.pl What is your default prog. lang? [Perl]: Cannot create second readline interface, falling back to dumb. What is your OS? [MacOS]: C:\tmp>

    And this limitation isn't just a MSWin32 thing:

    [canker:]$ perl foo.pl What is your default prog. lang? [Perl]: What is your OS? [MacOS]: [canker:]$ perl -ITerm-ReadLine-Perl-1.0303/blib/lib foo.pl What is your default prog. lang? [Perl]: Cannot create second readline interface, falling back to dumb. What is your OS? [MacOS]:

    Forcing Term::ReadLine to load the Stub personality should work fine.

    use strict; use warnings; BEGIN { $ENV{PERL_RL}='Stub'; }; use Term::UI; use Term::ReadLine; my $term = Term::ReadLine->new('lang'); my $reply = $term->get_reply( prompt => 'What is your default prog. la +ng?', default => 'Perl'); my $term2 = Term::ReadLine->new('OS'); $reply = $term2->get_reply( prompt => 'What is your OS?', default => ' +MacOS');

    And it does

    C:\tmp>perl -I Term-ReadLine-Perl-1.0303\blib\lib foo.pl What is your default prog. lang? [Perl]: What is your OS? [MacOS]: C:\tmp>

    And on a non-MSWin32 OS too

    [canker:]$ perl -ITerm-ReadLine-Perl-1.0303/blib/lib foo.pl What is your default prog. lang? [Perl]: What is your OS? [MacOS]: [canker:]$

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://960136]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-29 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found