1File::Remove(3) User Contributed Perl Documentation File::Remove(3)
2
3
4
6 File::Remove - Remove files and directories
7
9 use File::Remove 'remove';
10
11 # removes (without recursion) several files
12 remove( '*.c', '*.pl' );
13
14 # removes (with recursion) several directories
15 remove( \1, qw{directory1 directory2} );
16
17 # removes (with recursion) several files and directories
18 remove( \1, qw{file1 file2 directory1 *~} );
19
20 # trashes (with support for undeleting later) several files
21 trash( '*~' );
22
24 File::Remove::remove removes files and directories. It acts like
25 /bin/rm, for the most part. Although "unlink" can be given a list of
26 files, it will not remove directories; this module remedies that. It
27 also accepts wildcards, * and ?, as arguments for filenames.
28
29 File::Remove::trash accepts the same arguments as remove, with the
30 addition of an optional, infrequently used "other platforms" hashref.
31
33 remove
34 Removes files and directories. Directories are removed recursively
35 like in rm -rf if the first argument is a reference to a scalar that
36 evaluates to true. If the first arguemnt is a reference to a scalar
37 then it is used as the value of the recursive flag. By default it's
38 false so only pass \1 to it.
39
40 In list context it returns a list of files/directories removed, in
41 scalar context it returns the number of files/directories removed. The
42 list/number should match what was passed in if everything went well.
43
44 rm
45 Just calls remove. It's there for people who get tired of typing
46 remove.
47
48 clear
49 The "clear" function is a version of "remove" designed for use in test
50 scripts. It takes a list of paths that it will both initially delete
51 during the current test run, and then further flag for deletion at END-
52 time as a convenience for the next test run.
53
54 trash
55 Removes files and directories, with support for undeleting later.
56 Accepts an optional "other platforms" hashref, passing the remaining
57 arguments to remove.
58
59 Win32
60 Requires Win32::FileOp.
61
62 Installation not actually enforced on Win32 yet, since
63 Win32::FileOp has badly failing dependencies at time of writing.
64
65 OS X
66 Requires Mac::Glue.
67
68 Other platforms
69 The first argument to trash() must be a hashref with two keys,
70 'rmdir' and 'unlink', each referencing a coderef. The coderefs
71 will be called with the filenames that are to be deleted.
72
74 Bugs should always be submitted via the CPAN bug tracker
75
76 http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Remove
77 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Remove>
78
79 For other issues, contact the maintainer.
80
82 Adam Kennedy <adamk@cpan.org>
83
85 Some parts copyright 2006 - 2011 Adam Kennedy.
86
87 Taken over by Adam Kennedy <adamk@cpan.org> to fix the "deep readonly
88 files" bug, and do some package cleaning.
89
90 Some parts copyright 2004 - 2005 Richard Soderberg.
91
92 Taken over by Richard Soderberg <perl@crystalflame.net> to port it to
93 File::Spec and add tests.
94
95 Original copyright: 1998 by Gabor Egressy, <gabor@vmunix.com>.
96
97 This program is free software; you can redistribute and/or modify it
98 under the same terms as Perl itself.
99
100
101
102perl v5.12.3 2011-07-17 File::Remove(3)