1File::Remove(3) User Contributed Perl Documentation File::Remove(3)
2
3
4
6 File::Remove - Remove files and directories
7
9 version 1.60
10
12 use File::Remove 'remove';
13
14 # removes (without recursion) several files
15 remove( '*.c', '*.pl' );
16
17 # removes (with recursion) several directories
18 remove( \1, qw{directory1 directory2} );
19
20 # removes (with recursion) several files and directories
21 remove( \1, qw{file1 file2 directory1 *~} );
22
23 # removes without globbing:
24 remove( \1, {glob => 0}, '*');
25
26 # trashes (with support for undeleting later) several files
27 trash( '*~' );
28
30 File::Remove::remove removes files and directories. It acts like
31 /bin/rm, for the most part. Although "unlink" can be given a list of
32 files, it will not remove directories; this module remedies that. It
33 also accepts wildcards, * and ?, as arguments for filenames.
34
35 File::Remove::trash accepts the same arguments as remove, with the
36 addition of an optional, infrequently used "other platforms" hashref.
37
39 remove
40 Removes files and directories. Directories are removed recursively
41 like in rm -rf if the first argument is a reference to a scalar that
42 evaluates to true. If the first argument is a reference to a scalar,
43 then it is used as the value of the recursive flag. By default it's
44 false so only pass \1 to it.
45
46 If the next argument is a hash reference then it is a key/values of
47 options. Currently, there is one supported option of "'glob' => 0"
48 which prevents globbing. E.g:
49
50 remove(\1, {glob => 0}, '*');
51
52 Will not remove files globbed by '*' and will only remove the file
53 called asterisk if it exists.
54
55 In list context it returns a list of files/directories removed, in
56 scalar context it returns the number of files/directories removed. The
57 list/number should match what was passed in if everything went well.
58
59 rm
60 Just calls remove. It's there for people who get tired of typing
61 remove.
62
63 clear
64 The "clear" function is a version of "remove" designed for use in test
65 scripts. It takes a list of paths that it will both initially delete
66 during the current test run, and then further flag for deletion at END-
67 time as a convenience for the next test run.
68
69 trash
70 Removes files and directories, with support for undeleting later.
71 Accepts an optional "other platforms" hashref, passing the remaining
72 arguments to remove.
73
74 Win32
75 Requires Win32::FileOp.
76
77 Installation not actually enforced on Win32 yet, since
78 Win32::FileOp has badly failing dependencies at time of writing.
79
80 OS X
81 Requires Mac::Glue.
82
83 Other platforms
84 The first argument to trash() must be a hashref with two keys,
85 'rmdir' and 'unlink', each referencing a coderef. The coderefs
86 will be called with the filenames that are to be deleted.
87
88 expand
89 DO NOT USE. Kept for legacy.
90
91 undelete
92 DO NOT USE. Kept for legacy.
93
95 Bugs should always be submitted via the CPAN bug tracker
96
97 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Remove>
98
99 For other issues, contact the maintainer.
100
102 Adam Kennedy <adamk@cpan.org>
103
105 Taken over by Shlomi Fish (<http://www.shlomifish.org/>) while
106 disclaiming all rights and placing his modifications under
107 CC0/public-domain/MIT/any-other-licence.
108
109 Some parts copyright 2006 - 2012 Adam Kennedy.
110
111 Taken over by Adam Kennedy <adamk@cpan.org> to fix the "deep readonly
112 files" bug, and do some package cleaning.
113
114 Some parts copyright 2004 - 2005 Richard Soderberg.
115
116 Taken over by Richard Soderberg <perl@crystalflame.net> to port it to
117 File::Spec and add tests.
118
119 Original copyright: 1998 by Gabor Egressy, <gabor@vmunix.com>.
120
121 This program is free software; you can redistribute and/or modify it
122 under the same terms as Perl itself.
123
125 Websites
126 The following websites have more information about this module, and may
127 be of help to you. As always, in addition to those websites please use
128 your favorite search engine to discover more resources.
129
130 • MetaCPAN
131
132 A modern, open-source CPAN search engine, useful to view POD in
133 HTML format.
134
135 <https://metacpan.org/release/File-Remove>
136
137 • RT: CPAN's Bug Tracker
138
139 The RT ( Request Tracker ) website is the default bug/issue
140 tracking system for CPAN.
141
142 <https://rt.cpan.org/Public/Dist/Display.html?Name=File-Remove>
143
144 • CPANTS
145
146 The CPANTS is a website that analyzes the Kwalitee ( code metrics )
147 of a distribution.
148
149 <http://cpants.cpanauthors.org/dist/File-Remove>
150
151 • CPAN Testers
152
153 The CPAN Testers is a network of smoke testers who run automated
154 tests on uploaded CPAN distributions.
155
156 <http://www.cpantesters.org/distro/F/File-Remove>
157
158 • CPAN Testers Matrix
159
160 The CPAN Testers Matrix is a website that provides a visual
161 overview of the test results for a distribution on various
162 Perls/platforms.
163
164 <http://matrix.cpantesters.org/?dist=File-Remove>
165
166 • CPAN Testers Dependencies
167
168 The CPAN Testers Dependencies is a website that shows a chart of
169 the test results of all dependencies for a distribution.
170
171 <http://deps.cpantesters.org/?module=File::Remove>
172
173 Bugs / Feature Requests
174 Please report any bugs or feature requests by email to "bug-file-remove
175 at rt.cpan.org", or through the web interface at
176 <https://rt.cpan.org/Public/Bug/Report.html?Queue=File-Remove>. You
177 will be automatically notified of any progress on the request by the
178 system.
179
180 Source Code
181 The code is open to the world, and available for you to hack on. Please
182 feel free to browse it and play with it, or whatever. If you want to
183 contribute patches, please send me a diff or prod me to pull from your
184 repository :)
185
186 <https://github.com/shlomif/File-Remove>
187
188 git clone git://github.com/shlomif/File-Remove.git
189
191 Shlomi Fish <shlomif@cpan.org>
192
194 Please report any bugs or feature requests on the bugtracker website
195 <http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-Remove> or by email to
196 bug-file-remove@rt.cpan.org <mailto:bug-file-remove@rt.cpan.org>.
197
198 When submitting a bug or request, please include a test-file or a patch
199 to an existing test-file that illustrates the bug or desired feature.
200
202 This software is copyright (c) 1998 by Gabor Egressy.
203
204 This is free software; you can redistribute it and/or modify it under
205 the same terms as the Perl 5 programming language system itself.
206
207
208
209perl v5.34.0 2021-07-22 File::Remove(3)