File::Remove - Remove files and directories |
File::Remove - Remove files and directories
use File::Remove qw(remove);
# removes (without recursion) several files remove qw( *.c *.pl );
# removes (with recursion) several directories remove \1, qw( directory1 directory2 );
# removes (with recursion) several files and directories remove \1, qw( file1 file2 directory1 *~ );
# trashes (with support for undeleting later) several files trash qw( *~ );
File::Remove::remove removes files and directories. It acts like
/bin/rm, for the most part. Although unlink
can be given a list
of files, it will not remove directories; this module remedies that.
It also accepts wildcards, * and ?, as arguments for filenames.
File::Remove::trash accepts the same arguments as remove, with the addition of an optional, infrequently used ``other platforms'' hashref.
In list context it returns a list of files/directories removed, in scalar context it returns the number of files/directories removed. The list/number should match what was passed in if everything went well.
Installation not actually enforced on Win32 yet, since the Win32::FileOp manpage has badly failing dependencies at time of writing.
trash()
must be a hashref with two keys,
'rmdir' and 'unlink', each referencing a coderef. The coderefs
will be called with the filenames that are to be deleted.
See http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-Remove for the up-to-date bug listing.
Taken over by Adam Kennedy <adamk@cpan.org>, to fix the ``deep readonly files'' bug, and do some more cleaning up.
Taken over by Richard Soderberg <perl@crystalflame.net>, so as to port it to the File::Spec manpage and add tests.
Original copyright: (c) 1998 by Gabor Egressy, <gabor@vmunix.com>.
This program is free software; you can redistribute and/or modify it under the same terms as Perl itself.
File::Remove - Remove files and directories |