dreel has asked for the wisdom of the Perl Monks concerning the following question:

When i call CPAN i see: ←[4;mcpan> ←[1md←[0m←[1mf←[0m and every symblol quoted by ←[1 <symbol> ←[0 What is it? What i need to do for a normal input?
  • Comment on Strange bug in Windows CMD when using perl programs

Replies are listed 'Best First'.
Re: Strange bug in Windows CMD when using perl programs
by BrowserUk (Patriarch) on Jul 06, 2007 at 11:53 UTC

    The weird character sequences are ansi escape sequences used to highlight or color the text on a *nix console. cmd.exe doesn't do ansi escape sequences so it displayes them literally.

    Why CPAN.pm should be producing them I don't know. It didn't the last time I used it (a long while since). Maybe a new enhancement, and they got the test for OS wrong?

    It could be 'fixed' by using Win32::Console::ANSI within cpan.pm itself. This converts the ANSI escape sequences into appropriate Console API calls effectively emulating a ANSI complient terminal. But I wouldn't advise a user to make that modification.

    You need to work out why this happens for you, if nobody else is seeing the same problem?

    The first thing you need to do is tell whomever is listening the details of your system: Which OS (exact version)? Which CPAN.pm (exact version)? Which Perl (exact version)? Perl source: AS, home build, other supplier? If home build, which compiler (and version(s))? Do you use cygwin? Was your perl built under cygwin?

    Ie. a whole lot more than you have currently told us.

    My guess is that you are using a cygwin built perl install, but trying to use it from a non-sygwin shell. And CPAN.pm has been built expecting a *nix-like environment and so is producing the escape sequences. But that's total speculation.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Sorry for long time out. I'm newbie and i don't know how to setup notification by mail - there is so strange site intarface... My info: Win32 XP SP2 PRO, ActivePerl 5.8.820, GUI PPM, Perl installed by default ActiveState installer. CPAN - v 1.76_02
        My info: Win32 XP SP2 PRO, ActivePerl 5.8.820, GUI PPM, Perl installed by default ActiveState installer. CPAN - v 1.76_02

        Intriguing. Could you post the output from the command: set in a cmd.exe window?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Strange bug in Windows CMD when using perl programs
by almut (Canon) on Jul 06, 2007 at 13:08 UTC

    I think BrowserUk's guess is correct that you're using a cygwin built Perl / CPAN.pm on a terminal without support for ANSI escape sequences. In particular, I suspect it's Term::ReadLine (used under the hood) that's generating the escape sequences...

    So, as a workaround (if you can't or don't want to use a version "made for Windows"), you could try to disable Term::ReadLine's ornaments feature. One way to do so would be to set the environment variable PERL_RL to " o=0" (note that the last char is zero, not a captital O, and that - according to the manpage - there's supposed to be a space at the beginning (for me it also works without...)).

    I couldn't test it on Windows (because my Windows CPAN.pm doesn't have that problem...), but at least on my Linux box, the following succeeds in turning off any special rendering of the prompt, etc.:

    PERL_RL=" o=0" perl -MCPAN -e shell

    On Windows, I suppose that would be:

    set PERL_RL= o=0 perl -MCPAN -e shell

    If that doesn't help, you could also try turning off readline support entirely:

    perl -MCPAN -e "$CPAN::Suppress_readline=1; shell"

    But then, you'd of course no longer have readline support... ;)