How to add printing features - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to add printing features

satimissatimis Posts: 21Member
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.




  • WeirdofreakWeirdofreak Posts: 439Member
    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.