Debian Codegraph @

upstream/mageia-cauldron/man3pm/IO::Dir.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "IO::Dir 3pm"
61 .TH IO::Dir 3pm 2023-12-22 "perl v5.42.0" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 IO::Dir \- supply object methods for directory handles
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 8
71 \& use IO::Dir;
72 \& my $d = IO::Dir\->new(".");
73 \& if (defined $d) {
74 \& while (defined($_ = $d\->read)) { something($_); }
75 \& $d\->rewind;
76 \& while (defined($_ = $d\->read)) { something_else($_); }
77 \& undef $d;
78 \& }
79 \&
80 \& tie my %dir, \*(AqIO::Dir\*(Aq, ".";
81 \& foreach (keys %dir) {
82 \& print $_, " " , $dir{$_}\->size,"\en";
83 \& }
84 .Ve
85 .SH DESCRIPTION
86 .IX Header "DESCRIPTION"
87 The \f(CW\*(C`IO::Dir\*(C'\fR package provides two interfaces to perl\*(Aqs directory reading
88 routines.
89 .PP
90 The first interface is an object approach. \f(CW\*(C`IO::Dir\*(C'\fR provides an object
91 constructor and methods, which are just wrappers around perl\*(Aqs built in
92 directory reading routines.
93 .IP "new ( [ DIRNAME ] )" 4
94 .IX Item "new ( [ DIRNAME ] )"
95 \&\f(CW\*(C`new\*(C'\fR is the constructor for \f(CW\*(C`IO::Dir\*(C'\fR objects. It accepts one optional
96 argument which, if given, \f(CW\*(C`new\*(C'\fR will pass to \f(CW\*(C`open\*(C'\fR
97 .PP
98 The following methods are wrappers for the directory related functions built
99 into perl (the trailing \*(Aqdir\*(Aq has been removed from the names). See perlfunc
100 for details of these functions.
101 .IP "open ( DIRNAME )" 4
102 .IX Item "open ( DIRNAME )"
103 .PD 0
104 .IP "read ()" 4
105 .IX Item "read ()"
106 .IP "seek ( POS )" 4
107 .IX Item "seek ( POS )"
108 .IP "tell ()" 4
109 .IX Item "tell ()"
110 .IP "rewind ()" 4
111 .IX Item "rewind ()"
112 .IP "close ()" 4
113 .IX Item "close ()"
114 .PD
115 .PP
116 \&\f(CW\*(C`IO::Dir\*(C'\fR also provides an interface to reading directories via a tied
117 hash. The tied hash extends the interface beyond just the directory
118 reading routines by the use of \f(CW\*(C`lstat\*(C'\fR, from the \f(CW\*(C`File::stat\*(C'\fR package,
119 \&\f(CW\*(C`unlink\*(C'\fR, \f(CW\*(C`rmdir\*(C'\fR and \f(CW\*(C`utime\*(C'\fR.
120 .ie n .IP "tie %hash, \*(AqIO::Dir\*(Aq, DIRNAME [, OPTIONS ]" 4
121 .el .IP "tie \f(CW%hash\fR, \*(AqIO::Dir\*(Aq, DIRNAME [, OPTIONS ]" 4
122 .IX Item "tie %hash, 'IO::Dir', DIRNAME [, OPTIONS ]"
123 .PP
124 The keys of the hash will be the names of the entries in the directory.
125 Reading a value from the hash will be the result of calling
126 \&\f(CW\*(C`File::stat::lstat\*(C'\fR. Deleting an element from the hash will
127 delete the corresponding file or subdirectory,
128 provided that \f(CW\*(C`DIR_UNLINK\*(C'\fR is included in the \f(CW\*(C`OPTIONS\*(C'\fR.
129 .PP
130 Assigning to an entry in the hash will cause the time stamps of the file
131 to be modified. If the file does not exist then it will be created. Assigning
132 a single integer to a hash element will cause both the access and
133 modification times to be changed to that value. Alternatively a reference to
134 an array of two values can be passed. The first array element will be used to
135 set the access time and the second element will be used to set the modification
136 time.
137 .SH "SEE ALSO"
138 .IX Header "SEE ALSO"
139 File::stat
140 .SH AUTHOR
141 .IX Header "AUTHOR"
142 Graham Barr. Currently maintained by the Perl Porters. Please report all
143 bugs at <https://github.com/Perl/perl5/issues>.
144 .SH COPYRIGHT
145 .IX Header "COPYRIGHT"
146 Copyright (c) 1997\-2003 Graham Barr <[email protected]>. All rights reserved.
147 This program is free software; you can redistribute it and/or
148 modify it under the same terms as Perl itself.