Mailing List Archive

open file
hello there...

just wanna know how to open a text file in embperl

tnx
RE: open file [ In reply to ]
Hi,

>
> just wanna know how to open a text file in embperl
>
How do you do it in Perl?

open FH, "filename" ;

or ask more detailed what your problems is...

Gerald
Re: RE: open file [ In reply to ]
richter@ecos.de writes:
>>
>> just wanna know how to open a text file in embperl
>>
>How do you do it in Perl?
>
>open FH, "filename" ;
>
>or ask more detailed what your problems is...

this one didn't work... why?

<html><head><title>test</title></head>
<body>

[- open FILE, "/full/path/of/my/file"; -]
[$ while ($line = <FILE>) $]
[+ $line +]
[$ endwhile $]
[- close FILE; -]

</body>
</html>

.......................................................
: o/ Randy B. Nivales :
: <| randy@email.com.ph :
: / > http://www.emc.com.ph :
: (632) 638-4483 loc. 125 Phone :
: (632) 632-7319 Fax :
:......................................................:
Re: open file [ In reply to ]
The problem is the angle brackets in the statement "<FILE>". EmbPerl
translates them into HTML entities before passing the line off to Perl
to process. You need to set $optRawInput=1 in a block prior to the one
that contains your while statement. I usually make the following block
the first one in my EmbPerl file if I'm going to be doing any file I/O.

[- $optRawInput = 1 -]

Regards,
Bryan.

--
Bryan Thale
Motorola Labs, Networking and Infrastructure Research
mailto:thale@rsch.comm.mot.com

Randy Nivales wrote:

> this one didn't work... why?
>
> <html><head><title>test</title></head>
> <body>
>
> [- open FILE, "/full/path/of/my/file"; -]
> [$ while ($line = <FILE>) $]
> [+ $line +]
> [$ endwhile $]
> [- close FILE; -]
>
> </body>
> </html>
RE: open file [ In reply to ]
>
> The problem is the angle brackets in the statement "<FILE>". EmbPerl
> translates them into HTML entities before passing the line off to Perl
> to process. You need to set $optRawInput=1 in a block prior to the one
> that contains your while statement. I usually make the following block
> the first one in my EmbPerl file if I'm going to be doing any file I/O.
>
> [- $optRawInput = 1 -]
>

Yes, you could also set this option in your httpd.conf file, so you don't
have to write it all the time. You should do this anyway if you are using an
normal text editor for writing your code.

The other possibility is to do what a html editor would do, change your code
to &ltFILE&gt and last but nor least \<FILE> works also. Read the FAQ about
escaping and the section "inside Embperl" in the docs.

Gerald

> Regards,
> Bryan.
>
> --
> Bryan Thale
> Motorola Labs, Networking and Infrastructure Research
> mailto:thale@rsch.comm.mot.com
>
> Randy Nivales wrote:
>
> > this one didn't work... why?
> >
> > <html><head><title>test</title></head>
> > <body>
> >
> > [- open FILE, "/full/path/of/my/file"; -]
> > [$ while ($line = <FILE>) $]
> > [+ $line +]
> > [$ endwhile $]
> > [- close FILE; -]
> >
> > </body>
> > </html>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>



-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------
Re: RE: open file [ In reply to ]
tnx bryan and gerald...

its working now.


richter@ecos.de writes:
>> The problem is the angle brackets in the statement "<FILE>". EmbPerl
>> translates them into HTML entities before passing the line off to Perl
>> to process. You need to set $optRawInput=1 in a block prior to the one
>> that contains your while statement. I usually make the following block
>> the first one in my EmbPerl file if I'm going to be doing any file I/O.
>>
>> [- $optRawInput = 1 -]
>>
>
>Yes, you could also set this option in your httpd.conf file, so you don't
>have to write it all the time. You should do this anyway if you are using
>an
>normal text editor for writing your code.
>
>The other possibility is to do what a html editor would do, change your
>code
>to &ltFILE&gt and last but nor least \<FILE> works also. Read the FAQ
>about
>escaping and the section "inside Embperl" in the docs.
>
>Gerald


.......................................................
: o/ Randy B. Nivales :
: <| randy@email.com.ph :
: / > http://www.emc.com.ph :
: (632) 638-4483 loc. 125 Phone :
: (632) 632-7319 Fax :
:......................................................: