clean.pl
Submitted by ramiro on 29 August 2004 - 2:27am
Remove emacs and pod2html backup and autosave files in the directories given as arguments on the command-line.
#!/usr/bin/perl -w
# clean.pl removes emacs and pod2html backup and autosave files in
# the directories given as arguments on the command-line. It recurses
# subdirectores and also removes files beginning with a '.'.
#
# Copyright 2003, Ramiro Gómez.
#
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
use strict;
use File::Find;
die "Usage: $0 dir1 [dir2] [...]\n" unless @ARGV;
# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, @ARGV);
exit;
sub wanted {
(-d $_) && return;
if (/^#.*#$/ || /^.*~$/s) {
(unlink($_)) ? print "deleted $File::Find::name\n" :
warn "Can't delete $File::Find::name: $!\n";
}
}