itzMe has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
 Is it possible to add text formatting to contents of a file? If so where can i Find the resources? I have been trying hard to find some help. For eg: I have to underline the word "Happy" in a doc file. Or say I have to bold it. Is this kind of formatting possible using perl at the time of writing into a file.
Thanks in advance

update (broquaint): added formatting

Replies are listed 'Best First'.
Re: text formatting in a file
by gjb (Vicar) on Sep 05, 2003 at 09:35 UTC

    Do you want Microsoft Word files as a result? If so, you could have a look at RTF::Generator that allows Perl to produce RTF documents.

    You could also consider HTML formatting so that it can be viewed in a browser, in that case you could look at CGI.

    Hope this helps, -gjb-

      Thanks a lot!! :-)
Re: text formatting in a file
by Abigail-II (Bishop) on Sep 05, 2003 at 09:32 UTC
    Well, yes, of course. From the OSses point of view (and that's the point of view from Perl as well), a file is nothing more than a stream of bytes. "Formatting" is application dependent, but whatever formatting is being used, it remains a stream of bytes.

    Perl allows you to write any stream of bytes to a file, so it can deal with any formatting as well. Of course, the trick lies in knowing how the formatting is encoded by your application. There might be modules out there to help you, depending which formatting you require. Search CPAN.

    Abigail