I use Term::ReadLine::Gnu for its line-editing and input history retrieval capability. If I forget to install it, I'm reminded the moment I run a script that uses readline, hit the left-arrow at the prompt, and garbage splats out (^[[D). That's my cue to cpanm Term::ReadLine::Gnu.

However, while talking a Mac user through installing a Perl program I wrote that uses readline, I discovered that installing the Gnu version from scratch is harder than I'd thought. First, I had him install the Xcode Command Line Tools as a prerequisite for perlbrew, and then perl v5.34 and cpanm. But cpanm Term::ReadLine::Gnu failed: The libreadline you are using is the libedit library.  Use the GNU Readline Library. The simplest solution to this I could find involved installing homebrew. Homebrew's easy enough for me to use, but I felt like I was expending an awful lot of effort to provide a Mac terminal user with basic command-line editing.

Long story short, I installed Term::ReadLine::Perl and it mostly works (haven't fully tested it yet) but, because my prompt uses sequences from Term::ANSIColor, it writes '0m ' after the prompt! And if I remove those sequences, my keystrokes appear in white.

Since I normally don't have this kind of trouble doing something easy in Perl, I figure I'm overlooking something very obvious. Readline-Gnu "just worked" for me; can't Readline-Perl do the same, at least for line editing and input retrieval?


In reply to Term::ReadLine and line-editing by ibm1620

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.