in reply to Rmtree with exclude
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"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Rmtree with exclude
by Mery84 (Novice) on Dec 02, 2014 at 12:05 UTC | |
by james28909 (Deacon) on Dec 02, 2014 at 20:53 UTC |