[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Getting *last* line of info from file



At 23:32 96-05-30, Tim Judd wrote:

>Is there a quick way to get the last line of info of a text file into a
>variable (perferrably an array) that I can use other than doing a:
>
>while (<IN>) {
>  if ($_ eq "") {
>    @MyArrayValue = splice(/|/,$_);
>    }
>  }
>
>or thereabout..  I am not sure about the splice command again.  fields are
>separated by a  |  char, and lines separated by a  \n  character.

Yep.  You don't want splice, you want split:

    $lastLine = $_ while( $_ = <IN> );
    @MyArrayValue = split( /|/, $lastLine );

--Hal
Hal Wine <hal@dtor.com>     voice: 510/482-0597