in reply to Can anyone help me to improve this code, please?
A more aggressive approach is also possible, besides yours and tachyon's. The unlink call can take a list, so lets try unlinking all the unwanted files in each directory we see on the way down the tree.
Since find runs wanted() before entering a directory, this approach reduces the number of files find() must look at.#!/usr/bin/perl use strict; use warnings; use File::Find; our @ext = qw(.tmp .bak .$$$ .chk .old .gid .fts .ftg .log .dmp .--- .prv .temp); sub wanted { my $dir = $_; -d && unlink map {glob "$dir/*$_"} @ext; } find (\&wanted, $dir);
After Compline,
Zaxo
|
|---|