Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: peg - Perl _expression_ (GNU) grep script

by Clarendon4 (Acolyte)
on Nov 19, 2008 at 12:31 UTC ( [id://724565]=note: print w/replies, xml ) Need Help??


in reply to Re: peg - Perl _expression_ (GNU) grep script
in thread peg - Perl _expression_ (GNU) grep script

When I run peg, I get the messagec peg: failed to load Win32::Console::ANSI

which is strange because I can't find any reference to thie module in the peg source. Aside from this message, the program seems to work fine. Any idea where this message comes from?

This module is needed on Win32 to color the output. It is required at line 500 (not sure how you missed it!). NB. you do not call into it... it works by a form of side affect. Check it's docs (see below). If you're not on Win32, then something has gone screwy with the  $Is_Win32 varable.

Firstly i would highly reccomend installing this as once you've seen how easy and useful writing coloured output is, you'll likely find uses for it your existing scripts.

Failing that, add  $ENV{PEG_NO_WIN32_CONSOLE_ANSI} = 1 to your peg_ini.pl file and this will stop you seeing the error message. (Yes - it's a hack :-)

From the modules POD:

=head1 DESCRIPTION Windows NT/2000/XP does not support ANSI escape sequences in Win32 Con +sole applications. This module emulates an ANSI console for the script that + uses it and also converts the characters from Windows code page to DOS code + page (the so-called ANSI to OEM conversion). This conversion permits the di +splay of the accented characters in the console like in the Windows- based e +ditor used to type the script.

Replies are listed 'Best First'.
Re^3: peg - Perl _expression_ (GNU) grep script
by rovf (Priest) on Nov 19, 2008 at 14:22 UTC
    This module is needed on Win32 to color the output. It is required at line 500 (not sure how you missed it!).

    Neither do I. I looked at it with the 'less' pager and used the search function of less to look for ANSI. I have no idea why I got no match - now I'm doing the same, I can clearly find it.

    Failing that, add $ENV{PEG_NO_WIN32_CONSOLE_ANSI} = 1 to your peg_ini.pl file and this will stop you seeing the error message.

    Wouldn't it make sense to eval {} the loading of the ANSI module and simply switch off colouring if the module is not available? You do it at one place, but not at the other (which makes me wonder why you require the module twice.

    -- 
    Ronald Fischer <ynnor@mm.st>

      Wouldn't it make sense to eval {} the loading of the ANSI module and simply switch off colouring if the module is not available? You do it at one place, but not at the other (which makes me wonder why you require the module twice.

      ? Win32::Console::ANSI is only required once. The actual colouring interface used is provided by Term::ANSIColor.

      I think i may have misled you earlier... Win32::Console::ANSI _is_ needed for colouring, but it _also_ must be used to ensure the correct codepage is used on output (regardless of whether you want to colour the ouput). Consider this:

      c:\>perl -e "print '255 ', chr 255, qq(\n)" 255   c:\>perl -e "require Win32::console::ANSI; print '255 ', chr 255, qq(\ +n)" 255 ÿ

      The latter of these is the correct one for my console.

      You could argue that any script that does not require Win32::console::ANSI when printing to the console on Win32 is broken. I'd be interested to hear comments on this... especially if i'm wrong :-)

        ? Win32::Console::ANSI is only required once.

        Sorry, my mistake. I was just focusing on "ANSI" and mistook the require of require Term::ANSIColor. I should have read more carefully.

        You could argue that any script that does not require Win32::console::ANSI when printing to the console on Win32 is broken.

        If think this is an important point. If you are right, then I would consider it a severe mistake by ActiveState not having included it in their Perl distribution. I'm curious here about the comments of other Monks...

        -- 
        Ronald Fischer <ynnor@mm.st>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (9)
As of 2024-03-28 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found