Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

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


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

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 :-)

Replies are listed 'Best First'.
Re^5: peg - Perl _expression_ (GNU) grep script
by rovf (Priest) on Nov 20, 2008 at 08:46 UTC
    ? 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://724626]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-03-19 07:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found