in reply to Rmtree with exclude

File::Find in combination with File::Path is the route I would take here... it gives you a lot more flexibility. You can also restrict File::Find to just go down a specified depth to prevent a full recursion of all the subfolders.
#!/usr/bin/perl use warnings; use strict; use File::Find; use File::Path qw(make_path remove_tree); my $path="/opt/ssi/www/shop_templates/cache"; find(\&audit, $path); sub audit { # your logic for which paths you want to keep/toss. # in here, the following apply: # $File::Find::dir = /opt/ssi/www/shop_templates/cache # $_ = foo.ext # $File::Find::name = /opt/ssi/www/shop_templates/cache/foo.ext ... }