Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Understanding ANSI Output Failure

by marinersk (Priest)
on Mar 01, 2005 at 23:56 UTC ( [id://435658]=perlquestion: print w/replies, xml ) Need Help??

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

In researching this, I find modules like Win32::Console::ANSI,  Term::ANSIScreen, and Curses, so I'm not looking for a solution, per se. I'm looking to understand why this doesn't work otherwise.

In a Windows CMD console, having run ANSI.COM, using ActiveState Perl v5.6.1, output using print or even print STDOUT do not actually cause the ANSI sequences to be interpretted as they are in C when I do printf.

Why not? I can almost buy print failing due to some idea that bypassing STDOUTis more efficient (but not portable!), but if I pointedly ask to print to STDOUTI would expect it to go where the ANSI interpretter can intercept it.

What gives?

Replies are listed 'Best First'.
Re: Understanding ANSI Output Failure
by ikegami (Patriarch) on Mar 02, 2005 at 05:12 UTC
    I don't see how ANSI.COM could affect any 32-bit program. .COM programs are 16-bit DOS programs. ANSI.COM likely intercepts DOS print requests, something 32-bit programs (including 32-bit console programs) do not utilize. ActivePerl is a 32-bit program. Could your C programs have been 16-bit programs?
      The C programs were 32-bit console programs, so this probably isn't the source of the problem -- but I hadn't even considered it so thanks for the note.
      Hmm. Maybe you're right. The DOS program was a 16-bit program. When I try to use TYPE on a data file containing ANSI codes, I get the same results as my Perl script. Aha!
Re: Understanding ANSI Output Failure
by bibo (Pilgrim) on Mar 02, 2005 at 13:47 UTC
    From the readme of Win32::Console::Ansi

    "Windows NT/2000/XP does not support ANSI escape sequences in Win32 Console applications. This module emulate an ANSI console for the script which uses it."

    Also I found this link about loading ansi.sys

    As far as your original post, you indicate a perl program does not produce the same results as a C program, when both are writing to STDOUT. Have you tried unbuffering the output?

    $| = 1;

    --bibo

      Ah, I wasn't sure the buffering status of STDOUT could be adjusted. I'll give that a shot -- thanks!
        Nope. Didn't help. Hmm...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-24 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found