1IO::Dir(3pm)           Perl Programmers Reference Guide           IO::Dir(3pm)
2
3
4

NAME

6       IO::Dir - supply object methods for directory handles
7

SYNOPSIS

9           use IO::Dir;
10           $d = IO::Dir->new(".");
11           if (defined $d) {
12               while (defined($_ = $d->read)) { something($_); }
13               $d->rewind;
14               while (defined($_ = $d->read)) { something_else($_); }
15               undef $d;
16           }
17
18           tie %dir, 'IO::Dir', ".";
19           foreach (keys %dir) {
20               print $_, " " , $dir{$_}->size,"\n";
21           }
22

DESCRIPTION

24       The "IO::Dir" package provides two interfaces to perl's directory read‐
25       ing routines.
26
27       The first interface is an object approach. "IO::Dir" provides an object
28       constructor and methods, which are just wrappers around perl's built in
29       directory reading routines.
30
31       new ( [ DIRNAME ] )
32           "new" is the constructor for "IO::Dir" objects. It accepts one
33           optional argument which,  if given, "new" will pass to "open"
34
35       The following methods are wrappers for the directory related functions
36       built into perl (the trailing `dir' has been removed from the names).
37       See perlfunc for details of these functions.
38
39       open ( DIRNAME )
40       read ()
41       seek ( POS )
42       tell ()
43       rewind ()
44       close ()
45
46       "IO::Dir" also provides an interface to reading directories via a tied
47       hash. The tied hash extends the interface beyond just the directory
48       reading routines by the use of "lstat", from the "File::stat" package,
49       "unlink", "rmdir" and "utime".
50
51       tie %hash, 'IO::Dir', DIRNAME [, OPTIONS ]
52
53       The keys of the hash will be the names of the entries in the directory.
54       Reading a value from the hash will be the result of calling
55       "File::stat::lstat".  Deleting an element from the hash will delete the
56       corresponding file or subdirectory, provided that "DIR_UNLINK" is
57       included in the "OPTIONS".
58
59       Assigning to an entry in the hash will cause the time stamps of the
60       file to be modified. If the file does not exist then it will be cre‐
61       ated. Assigning a single integer to a hash element will cause both the
62       access and modification times to be changed to that value. Alterna‐
63       tively a reference to an array of two values can be passed. The first
64       array element will be used to set the access time and the second ele‐
65       ment will be used to set the modification time.
66

SEE ALSO

68       File::stat
69

AUTHOR

71       Graham Barr. Currently maintained by the Perl Porters.  Please report
72       all bugs to <perl5-porters@perl.org>.
73
75       Copyright (c) 1997-2003 Graham Barr <gbarr@pobox.com>. All rights
76       reserved.  This program is free software; you can redistribute it
77       and/or modify it under the same terms as Perl itself.
78
79
80
81perl v5.8.8                       2001-09-21                      IO::Dir(3pm)
Impressum