in reply to File::Find question
For me File::List is easier, though.
use File::List; my $dir= "/home/toma/perl/examples/filelist"; my $search = new File::List($dir); # \ needed to make . an ordinary character in the regex my @files = @{ $search->find('\.b$') }; foreach my $filename (@files) { if (-f $filename and -w $filename) { print "Can probably remove $filename\n"; # Uncomment when this seems to work: # unlink $filename or die "Can't unlink $filename"; } }
Note: This code has not been tested. Test before using. Use at own risk. Be careful not to unlink a directory!
It should work perfectly the first time! - toma
|
|---|