I can't test this here, but would this work?

while(<FILE>){
  $scalar = $_;
}
print $scalar;

$scalar should have the last line in it unless the EOF gets passed or
something.  That way you still end up reading through the entire file, but
you don't have to slurp up the entire file to memory.

-----Original Message-----
From: Connie Chan
To: Karen Liew Ying Ping; [EMAIL PROTECTED]
Sent: 6/24/02 3:20 AM
Subject: Re: Reading File

open (FILE, "yourfile.txt");
my @FD = <FILE>;
close (FILE);

my $lastline = $FD[$#FD]

Hope this help,
Smiley Connie =)


----- Original Message ----- 
From: "Karen Liew Ying Ping" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 24, 2002 6:05 PM
Subject: Reading File


Hi,

Let's say I'm opening a file.
How do I read the last line of the file?
is there any function in doing so?

Thanks.




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

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

Reply via email to