On Aug 4, 2004, at 9:57 AM, james derry wrote:

hi, all,

the answer to my question in probably obvious to all but me, but i don't know how to test for end-of-file. basically, i want the conditional to test TRUE if $lineCounter eq $lineLength OR the end-of-file has been reached. i can't find how do this in my learning perl or the perl faqs i've looked through.

if ($lineCounter == $lineLength || EOF){do something;}

Perl has an eof() routine. Just replace the EOF above with eof.

Are you sure you need this though? Perl generally handles this kind of thing for us, with the proper setup:

while (my $line = <FILE_HANDLE>) { # will be false when we've read all lines
# work with each line in $line here...
}


Hope that helps.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to