in reply to Re: Is too little too much? Coding under the microscope...
in thread Is too little too much? Coding under the microscope...

There is a problem with using readdir(LOGS) or die, and that's it's normal for readdir to return a false value. If you have read all the files in a directory, readdir will return undef (in scalar context, an empty list in list context), signalling you have finished reading. dieing in this situation would really be bad. Also, if you have a file named 0 in your directory, readdir returns a false value.

-- Abigail

Replies are listed 'Best First'.
Re: Re: Is too little too much? Coding under the microscope...
by bluto (Curate) on Jun 28, 2001 at 22:36 UTC
    You are right, of course. In fact, it looks like you'd have to do something like...
    my @a = readdir(FH); die $! if !@a and $!;
    ... to catch an error for readdir (in list context). Now that I think about it, readdir() either fails when you fail to open the filehandle, in which case you should have check opendir(), or you have something really strange happen (i.e. reading from a NFS-ish directory and the server goes away and you have the filesystem soft mounted). So it was a very bad example.

    -- bluto