Title: RE: how to match the last line in a file

could you not also do
open(FILE, "file_for_read.txt");
@array = <FILE>;
$last_line_number = $#array;
$last_line = $array[$last_line_number];

??

you may have to add one or subtract one I can't remember =)


-----Original Message-----
From: Dave Crawford [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 19, 2003 2:58 PM
To: Grace Huang; [EMAIL PROTECTED]
Subject: Re: how to match the last line in a file


Do you only need the last line or are you processing each line of the file?
If you only need the last line you can use:

while (<READIN>) {
    $last = $_;
    }

# ... perform your match on $last here

-Dave

----- Original Message -----
From: "Grace Huang" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 19, 2003 3:16 PM
Subject: how to match the last line in a file


Hi

I use "while (my $line = <READIN>) {...} to read a file, how can I determine
if a line is the last line in the file since I need to match something in
the last line? Thanks.

Grace
------------------------------------------------------
Yiting (Grace) Huang
Bioinformatics Programmer
Peter Myler's Lab
Seattle Biomedical Research Institute
206-284-8846 ext. 373

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to