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]