Main Content

Coloured text in a terminal from Perl

Archive - Originally posted on "The Horse's Mouth" - 2006-05-29 14:28:36 - Graham Ellis

If you're looking to do something in Perl and the back of your mind tells you that, surely, someone's done this before then there are two things to note:
• Someone probably HAS and
• It's probably available on the CPAN or as a built in module.

Thus when I was asked the question "How do I get coloured text in a terminal window in Perl" last week, I know there was going to be a module out there - and there is - Term::ANSIColor.

As ever, there's an excellent set of reference notes on th CPAN, but no complete cut-and-paste-this sample for you to try out, so I've written one and it's available here.