use File::Spec; my $path=File::Spec->join($server,$folder); rmtree($path) if (dir_has($path,$regex));