writing to a notepad in perl

writing to a notepad in perl

am 29.11.2007 05:32:09 von Rajendra

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.

Re: writing to a notepad in perl

am 29.11.2007 05:46:12 von jurgenex

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

Re: writing to a notepad in perl

am 29.11.2007 06:42:05 von sanjeeb

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? The=
n
> 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.

Re: writing to a notepad in perl

am 29.11.2007 13:16:22 von Tad McClellan

rajendra wrote:


> open(f,">test.txt");


You should use uppercase filehandles.

You should always, yes *always*, check the return value from open():

open F, '>test.txt' or die "could not open 'test.txt' $!";

Even better, use lexical filehandles and the 3-arg form of open:

open my $F, '>', 'test.txt' or die "could not open 'test.txt' $!";


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Re: writing to a notepad in perl

am 30.11.2007 15:43:55 von hymie_

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.

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

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

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

Re: writing to a notepad in perl

am 30.11.2007 18:20:17 von RedGrittyBrick

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 hymie@lactose.homelinux.net
> ------------------------ 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" :-)

Re: writing to a notepad in perl

am 30.11.2007 18:22:36 von RedGrittyBrick

RedGrittyBrick wrote:
> print "plain *bold* _italic_ in some viewers \n";

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

:-(

Re: writing to a notepad in perl

am 30.11.2007 18:53:12 von Michele Dondi

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-Err or.aspx


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^ ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Re: writing to a notepad in perl

am 03.12.2007 14:35:44 von hymie_

In our last episode, the evil Dr. Lacto had captured our hero,
RedGrittyBrick , who said:
>hymie! wrote:
>>
>> 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.

To be honest, I'm not at all familiar with RTF, but you make a good point
about "text" vs "plain text".

>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? :)

--
hymie! http://lactose.homelinux.net/~hymie hymie@lactose.homelinux.net
------------------------ Without caffeine for 398 days ------------------------

Re: writing to a notepad in perl

am 04.12.2007 01:24:46 von Michele Dondi

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^ ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,