You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by "Angeles, Michael (Michael)" <an...@lucent.com> on 2001/08/15 14:54:29 UTC
RE: question RE: using file handler to read a flatfile and spit o
ut s plit values
Thanks, Luis. I was aware of [$ foreach $] but wasn't sure if it could be
used when opening a file handler. Thanks again.
-Mike
Michael Angeles | Information Specialist
Lucent Tech./Bell Labs | Integrated Info. Solutions
e: angeles@lucent.com | t: 908 582 5589 | m: 917 613 6935
> -----Original Message-----
> From: Luiz Fernando B. Ribeiro [mailto:listas_embperl@athome.pro.br]
> Sent: Wednesday, August 15, 2001 8:35 AM
> To: Angeles, Michael (Michael)
> Subject: Re: question RE: using file handler to read a
> flatfile and spit
> out s plit values
>
>
> Hi Michael,
>
> Reply:
>
> AMM> A simple script to read a flatfile works when I run it
> from the shell as a
> AMM> .pl file (formmated differently of course). Doesn't put
> anything out onto
> AMM> browser running as an .epl file, however. Any ideas?
> Have a feeling it's
> AMM> something to do with doing printf?
>
> AMM> [-
> AMM> $database = "/u4/angeles/public_html/test2.dat";
>
> AMM> open(DB,$database) || die "error opening database";
>
> AMM> while(<DB>){
> AMM> @data = (<DB>);
> AMM> }
>
> -] # close the -] here
>
> Here you can use the Embperl [$ foreach $] construction:
>
> AMM> foreach $data(@data){
> AMM> ($firstname,$lastname,$msg)=split(/\s*\|\s*/,$data);
> AMM> printf "First Name: $firstname";
> AMM> printf "Last Name: $lastname";
> AMM> printf "Message : $msg";
> AMM> }
>
> [$ foreach $data @data $]
> [- ($firstname,$lastname,$msg)=split(/\s*\|\s*/,$data); -]
> First Name: [+$firstname+]
> Last Name: [+$lastname+]
> ...
> [$ endforeach $]
>
> [- close DB -]
>
>
> Bye,
>
> Luiz Fernando B. Ribeiro
> ----------------------------
> At Home - Design e Internet
> contato@athome.pro.br
> athome@uol.com.br
>
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org