Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: How to print colored word in text file

by ww (Archbishop)
on Jun 21, 2013 at 12:02 UTC ( #1040138=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to print colored word in text file
in thread How to print colored word in text file

Same problem as hdb; may be user-error, but I can't recall ever (on M$ osen) making Term::ANSIColor work as advertized.

If you didn't program your executable by toggling in binary, it wasn't really programming!

  • Comment on Re^3: How to print colored word in text file

Replies are listed 'Best First'.
Re^4: How to print colored word in text file
by dasgar (Curate) on Jun 21, 2013 at 13:08 UTC

    I haven't tried doing colored text in a Windows command prompt before. However, I know that Damian Conway's Regexp::Debugger module is definitely creating colored text within a command prompt on Windows 7. It looks like he's using Win32::Console::ANSI to get the colored text to show up in the command prompt.

      Thanks a lot this works for me. Example I tried from the documentation:

      use Win32::Console::ANSI; print "\e[1;34mThis text is bold blue.\e[0m\n"; print "This text is normal.\n"; print "\e[33;45;1mBold yellow on magenta.\e[0m\n"; print "This text is normal.\n";
        ++hdb. For something different, I would use Win32::Console::ANSI and Term::ANSIColor::Print.
        #!/usr/bin/perl BEGIN { $| = 1; $^W = 1; eval { require Readonly; }; } use strict; use warnings; use Win32::Console::ANSI; use Term::ANSIColor::Print; my $print = Term::ANSIColor::Print->new(); $print->bold_blue( "This text is bold blue." ); $print->normal( "This text is normal" ); $print->bold_yellow_on_magenta( "This text is bold yellow on magenta", ); $print->normal( "This text is normal." ); print "To print a specific word such as ERROR in red: "; $print->red("ERROR");
        I don't have access to a Windows machine, so it isn't tested. Please let me know if it works for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1040138]
help
Chatterbox?
[Lady_Aleena]: Updating things can be fun, if there is a better way to do it.
[Corion]: Lady_Aleena: Mostly, it's just housekeeping, but it inspires me about things I could do with it, so that's good ;)
[Lady_Aleena]: By the way, I stopped by to let someone know I'm still alive, though I haven't found anything to write in perl for a while now.
[Lady_Aleena]: I need inspiration.

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2017-09-24 18:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (274 votes). Check out past polls.

    Notices?