jake9115
jake9115

Reputation: 4084

How to return text to normal color after using the perl module ANSIColor?

I recently found the very fun perl module Term::ANSIColor for changing my text color. Basically, all i need to do to change perl stdout text color is something like...

print color("red")."My sample text\n";

However, after exiting the script, my terminal is now only printing in red as well! Is there some function for return the console to the original color that I can include at the end of my script?

Upvotes: 1

Views: 701

Answers (3)

Slaven Rezic
Slaven Rezic

Reputation: 4581

Use colored() instead of color(). This will reset the coloring after the string is printed:

print colored("My sample text\n", "red");

Upvotes: 8

Deck
Deck

Reputation: 1979

Term::ANSIColor doc page says that to get back to normal text you should use reset keyword.

print color 'bold blue';
print "This text is bold blue.\n";
print color 'reset';
print "This text is normal.\n";

Also I recommend to look at Constant Interface

Upvotes: 4

mpapec
mpapec

Reputation: 50657

You can try,

print color 'reset';

Upvotes: 4

Related Questions