opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
@dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
closedir DIR;
Which we can adapt like:
opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
@files = grep {/\.txt$/} readdir(DIR);
closedir DIR;
unlink @files;
Notice that unlink is not related to the directory functions. Also, arturo reminded me that the filesystem is considered untrusted, so this still may not work with Taint checking. |