I'd like to print some output to the terminal in color when the terminal supports colors, print it plain otherwise. Also, I'd like no color when the program is not run interactively, e.g. when piped into grep.
What's the best way to do this in Perl? I'm hoping for some API that's sort of like this:
printColorMaybe( RED, "Hi", PLAIN, " mom!\n" );
where the implementation will ignore the color codes when not appropriate.