in reply to Term ReadLine in OS X

I'm running Mac OS X 10.7.4 and can't reproduce your problem. I tried with both Perl v5.12.3 and Perl v5.14.2 - both produced:

$ pm_readline_mac.pl Enter your arithmetic expression: 1+2 3 Enter your arithmetic expression: 8/2 4 Enter your arithmetic expression: exit $

The only difference is the text I enter: under 5.12.3 it is emboldened; under 5.14.2 it is not.

To run your code, I simply added the following lines before your code:

use strict; use warnings; use Term::ReadLine;

I recall that I initially had problems with CPAN prompts. Installing Term::ReadLine::Perl fixed the problem. Unfortunately, that was some time ago and I don't remember the exact nature of the problem; although, I don't recall getting warning messages. In the absence of other solutions, you could try installing Term::ReadLine::Perl if you don't already have it.

When I was first looking at changing to a Mac, I asked: "Are there any major Perl issues with Mac OS X Lion?". I followed advice regarding installing a separate version of Perl: I took the Perlbrew path - others (MacPorts, ActiveState) are also suggested. You may want to consider these options before adding or updating modules used by your system Perl.

-- Ken

Replies are listed 'Best First'.
Re^2: Term ReadLine in OS X
by mightymouse3062 (Novice) on May 27, 2012 at 01:54 UTC
    I installed Term::ReadLine::Perl and it fixed the problem. I also installed MacPorts. Now I am getting the error
    Cannot open /dev/tty for read at /Users/mike/readline.pl
    Thanks, Mike

      That sounds like you installed Term::ReadLine::Perl before MacPorts. Please advise the order of installations.

      Please also show the code in /Users/mike/readline.pl.

      As stated, I "took the Perlbrew path" - I don't have a lot of experience with MacPorts. The MacPorts Guide may be of use to you.

      -- Ken

        I installed Term::ReadLine::Perl and then ran my program, which gave me the new error. After that, I installed MacPorts.

        Here is my code:
        #!/usr/bin/perl -w use Term::ReadLine; use strict; my $term = Term::ReadLine->new('readLine'); my $prompt = "> "; my $OUT = $term->OUT || \*STDOUT; print "Enter: \n"; my $result = $term->readline($prompt);
        Could I install Perlbrew alongside MacPorts and go that route?
        Thanks,
        Mike