writing to a notepad in perl

Discussion in 'Perl Misc' started by rajendra, Nov 29, 2007.

  1. rajendra

    rajendra Guest

    Hello All,

    Whenever we want to write some content to a text file, we open that file and
    write in that file as shown below:

    open(f,">test.txt");
    print f "This is test";

    But there a way I can write a text file in fonts i.e some content in BOLD
    letters and some in italised etc using perl functions.
     
    rajendra, Nov 29, 2007
    #1
    1. Advertising

  2. rajendra wrote:
    > But there a way I can write a text file in fonts i.e some content in
    > BOLD letters and some in italised etc using perl functions.


    Sure. You can output HTML or TeX or PostSript or RTF or PDF or whatever
    format you are thinking about. Do you have something specific in mind? Then
    just do a search on CPAN and chances are pretty good that you will find a
    module that supports that format.

    jue
     
    Jürgen Exner, Nov 29, 2007
    #2
    1. Advertising

  3. rajendra

    sanjeeb Guest

    On Nov 29, 9:46 am, "Jürgen Exner" <> wrote:
    > rajendra wrote:
    > > But there a way I can write a text file in fonts i.e some content in
    > > BOLD letters and some in italised etc using perl functions.

    >
    > Sure. You can output HTML or TeX or PostSript or RTF or PDF or whatever
    > format you are thinking about. Do you have something specific in mind? Then
    > just do a search on CPAN and chances are pretty good that you will find a
    > module that supports that format.
    >
    > jue


    Check Win32::OLE in capn to suit most of the formatting stuffs.
     
    sanjeeb, Nov 29, 2007
    #3
  4. hymie! wrote:
    > In our last episode, the evil Dr. Lacto had captured our hero,
    > "rajendra" <>, who said:
    >
    >> But there a way I can write a text file in fonts i.e some content in BOLD
    >> letters and some in italised etc using perl functions.


    First you have to choose a system for representing the formatting
    information. There are many.
    #!perl
    use strict; use warnings;
    print "plain *bold* _italic_ in some viewers \n";

    I'd search CPAN for more useful approaches.

    >
    > The whole concept of a text file is based on it being text (that is,
    > unformatted).


    I know what you mean, and it's pertinent since the OP mentions notepad,
    but I'd say "plain text" where you say "text". To me, Rich Text Format
    (RTF) is text too, though only just :). Widely used MIME types like
    "text/plain", "text/rtf" and "text/html" tend to reinforce this idea.

    >
    > If you include formatting information, then it is no longer a text file.


    IKWYM but http://c2.com/cgi/wiki?TextFilter

    >
    > --hymie! http://lactose.homelinux.net/~hymie
    > ------------------------ Without caffeine for 395 days ------------------------


    Just a thought: if you change your "signature" separator to hyphen
    hyphen space newline then most newsreaders will recognise it as a
    "signature", display it differently and automatically omit it from replies.

    Although minus minus space newline is (arguably) formatting information,
    your posting is still recognisably "text" :)
     
    RedGrittyBrick, Nov 30, 2007
    #4
  5. RedGrittyBrick wrote:
    > print "plain *bold* _italic_ in some viewers \n";


    Dang!
    print "plain _underlined_ *bold* /italic/ in some viewers \n";

    :-(
     
    RedGrittyBrick, Nov 30, 2007
    #5
  6. On Fri, 30 Nov 2007 17:20:17 +0000, RedGrittyBrick
    <> wrote:

    >>> But there a way I can write a text file in fonts i.e some content in BOLD
    >>> letters and some in italised etc using perl functions.

    >
    >First you have to choose a system for representing the formatting
    >information. There are many.
    > #!perl
    > use strict; use warnings;
    > print "plain *bold* _italic_ in some viewers \n";
    >
    >I'd search CPAN for more useful approaches.


    You somehow (loosely) remind me of one of the funniest wtf I've read
    as of recently:

    http://worsethanfailure.com/Articles/Notepad-Translation-Error.aspx


    Michele
    --
    {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
    (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
    ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
    256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
     
    Michele Dondi, Nov 30, 2007
    #6
  7. On Mon, 03 Dec 2007 07:35:44 -0600, hymie_@_lactose.homelinux.net
    (hymie!) wrote:

    >>Just a thought: if you change your "signature" separator to hyphen
    >>hyphen space newline then most newsreaders will recognise it as a
    >>"signature", display it differently and automatically omit it from replies.

    >
    >*gasp* there are people other than me using newsreaders? :)


    Probably, most people here.


    Michele
    --
    {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
    (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
    ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
    256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
     
    Michele Dondi, Dec 4, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JDS
    Replies:
    4
    Views:
    8,278
    ForestHonerkamp
    Nov 11, 2008
  2. fgdg
    Replies:
    236
    Views:
    3,680
    dorayme
    Feb 21, 2007
  3. Replies:
    2
    Views:
    442
  4. randy
    Replies:
    5
    Views:
    125
    Michele Dondi
    Jul 22, 2003
  5. JDS
    Replies:
    3
    Views:
    197
    gnari
    May 24, 2004
Loading...

Share This Page