How to add printing features

Hi folks,

Please advise how to add 'bold', 'italic', 'colour', etc. such features to the printout. Can HTML syntax work on perl? I tried seeming not applicable.




  • It's based on where the output goes. If it goes to a web browser, like in a CGI script, HTML will naturally work, but since you're usually running it from a terminal, you'll have to use the teminal's escape codes for them. My command prompt for instance is surrounded with [e[4m] and [e[0m]. The [ ] tells it that what's inside isn't printed - it will work without them, but the wrapping will get screwed up. The e[xm tells it to display all following text according to x. 1 is bold (which really just brightens the color), 4 is underlined, 5 blinks, 7 is highlighted. 3x and 4x change the foreground and background colors respecively, and 0 resets it to normal. I don't know any others, but it's probably different between terminals anyway. You can use several in one command with semi-colons, so e[1;4m is bold and underlined.

    You may want to take a look at the CPAN module Color::Output (
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion