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 qw(remove);
10
11 # removes (without recursion) several files
12 remove qw( *.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 qw( *~ );
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
36 that evaluates to true. If the first arguemnt is a reference to a
37 scalar then it is used as the value of the recursive flag. By
38 default it's 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.
42 The list/number should match what was passed in if everything went
43 well.
44
45 rm Just calls remove. It's there for people who get tired of typing
46 remove.
47
48 trash
49 Removes files and directories, with support for undeleting later.
50 Accepts an optional "other platforms" hashref, passing the remain‐
51 ing arguments to remove.
52
53 Win32
54 Requires Win32::FileOp.
55
56 Installation not actually enforced on Win32 yet, since
57 Win32::FileOp has badly failing dependencies at time of writ‐
58 ing.
59
60 OS X
61 Requires Mac::Glue.
62
63 Other platforms
64 The first argument to trash() must be a hashref with two keys,
65 'rmdir' and 'unlink', each referencing a coderef. The coderefs
66 will be called with the filenames that are to be deleted.
67
69 See http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-Remove for the up-to-
70 date bug listing.
71
73 Taken over by Adam Kennedy <adamk@cpan.org>, to fix the "deep readonly
74 files" bug, and do some more cleaning up.
75
76 Taken over by Richard Soderberg <perl@crystalflame.net>, so as to port
77 it to File::Spec and add tests.
78
79 Original copyright: (c) 1998 by Gabor Egressy, <gabor@vmunix.com>.
80
81 This program is free software; you can redistribute and/or modify it
82 under the same terms as Perl itself.
83
84
85
86perl v5.8.8 2008-02-23 File::Remove(3)