Thank you very much guys.

Rob, sorry but it didn't work

            open (DATOS, "$bd") || die "Error: no se puede abrir el
archivo";

            while ($registro=<DATOS>) {}

            ($file, $vot_tot, $ult_vot, $sum_vot) = split(/:/,$registro);

            $lineas = $.;
            close (DATOS);

I had a good feeling about it but wasn't enough.

David. It made it:

            open (DATOS, "$bd") || die "Error: no se puede abrir el
archivo";

            while ($registro=<DATOS>) {
               $registro = $_;
            }

            ($file, $vot_tot, $ult_vot, $sum_vot) = split(/:/,$registro);

            $lineas = $.;
            close (DATOS);


Altough I'd like to avoid $registro = $_;   in order to use less lines.

Anyway thank you.

-rm-

----- Original Message -----
From: Wagner, David --- Senior Programmer Analyst --- WGO
<[EMAIL PROTECTED]>
To: 'Ramón Chávez' <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, February 07, 2003 10:58 AM
Subject: RE: Reading Plain Text File - help


Ramón Chávez wrote:
> I'm trying to read the last line on a Plain text File.
>
> But when I use:
>
>     open (DATOS, "$bd") || die "Error: no se puede abrir el archivo";
>     while
> ATOS>){
>     $registro = <DATOS>;
>     }
>
> I don't get any value on $registro
>
> I need to insert   ----    $inicio = <DATOS>;  ------
>
> This way to get the the last line of my file in $registro:
>
>     open (DATOS, "$bd") || die "Error: no se puede abrir el archivo";
>     $inicio = <DATOS>;
>     while (<DATOS>){
>     $registro = <DATOS>;
>
>
> It sounds weird for me. But maybe I'm missing something. I mean, the
> script works at last, but I'd like better to have one line of code
> less.
>
> Can anyone help me????

 You are working too hard at it  Just replace $registro = <DATOS> with
$registro = $_;  and it will work for you.  What you are doing are double
reads of the file.  What while ( <DATOS> ) is reading one record into $_ and
the other line is reading into $registro. The file you are working with
probably has an odd number of lines. So just do:
     while (<DATOS>){
       $registro = $_;
      }

Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to