Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

perlfunc:readdir

by gods (Initiate)
on Aug 24, 1999 at 22:42 UTC ( [id://289]=perlfunc: print w/replies, xml ) Need Help??

readdir

See the current Perl documentation for readdir.

Here is our local, out-dated (pre-5.6) version:


readdir - get a directory from a directory handle



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.

If you're planning to filetest the return values out of a readdir(), you'd better prepend the directory in question. Otherwise, because we didn't chdir() there, it would have been testing the wrong file.

    opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
    @dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
    closedir DIR;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-09-15 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.