in reply to Grep on a list of files in directory

Take a look at readdir. It doesn't return a list! My apologies - it does in list context. Take a look anyway for an example of the error checking.

You should add some error checking to opendir. Also, use strict; and use warnings; may provide useful information.

Update: As above - thanks graff

-- Ken

Replies are listed 'Best First'.
Re^2: Deferencing a hash
by graff (Chancellor) on Oct 29, 2010 at 03:26 UTC
    Take a look at readdir. It doesn't return a list!

    Um, look again.

    readdir DIRHANDLE
    Returns the next directory entry for a directory opened by "opendir". If used in list context, returns all the rest of the entries in the directory. If there are no more entries, returns an undefined value in scalar context or a null list in list context.
    Using readdir in a list context is a frequently used idiom.

      Thanks for pointing that out - I've updated the node.

      -- Ken