I used Perl Regex Tester to create a regex that matches _ in the path, if found then it uses rmtree to remove it. This is completely untested as i am getting ready for work!use strict; use warnings; use File::Slurp; use File::Path qw( remove_tree ); use Cwd; my $dir = shift; #path/to/cache my @dirs = read_dir( $dir ); my $path = getcwd( $dir ); for (@dirs) { next if ( -f $_ ); if ( $_ !~ /(?:_)/ ) { my $removed = $path . "$dir/$_"; remove_tree($removed); print "removed : $removed\n"; } }
In reply to Re: Rmtree with exclude
by james28909
in thread Rmtree with exclude
by Mery84
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |