From:                   Ahmed Moustafa <[EMAIL PROTECTED]>
> Jenda Krynicky wrote:
> > Anyway when reading file you don't need any end of line character,
> > the system KNOWs how long is the file at the moment and <FILEHANDLE>
> > will return undef if you've read all there is.
> 
> I didn't get what you meant by "<FILEHANDLE> will return undef if
> you've read all there is"; would you explain more, please?

if you open a file and the read it line by line by

        $line = <FILEHANDLE>;

then as soon as you have read all lines in the file, the $line will get 
set to undefined. That is if you want to read and process all lines in 
a file you do this:

        open FILEHANDLE, "< $filename"
                or die "Cannot open $filename : $!\n";

        while (defined ($line = <FILEHANDLE>)) {
                do whatever you like with $line
        }
        # now we've read "all there is" = "all data in the file"
        close FILEHANDLE;

The file doesn't have to end with any special character, and most 
likely will not.

Jenda

=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
                                        --- me

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

Reply via email to