Critiques ??
As a general rule, avoid subroutine prototypes unless you have good reason for them. (See, e.g., Far More than Everything You've Ever Wanted to Know about Prototypes in Perl -- by Tom Christiansen.) With the prototype removed, and employing some Perl idioms, sub fexist can be simplified to:
sub fexist { for (glob $_[0]) { return 3 if -l; return 2 if -d; return 1 if -f; } return 0; }
Improvements ??
Since the aim is to cleanup unwanted files, perhaps it would be better to integrate sub fexist with the cleanup code? Something like this:
use v5.14; ... sub cleanup { for (glob $_[0]) { cleanup_link($_) when -l; cleanup_dir ($_) when -d; cleanup_file($_) when -f; } }
Hope that helps,
Athanasius <°(((>< contra mundum
In reply to Re^3: File existence check failure
by Athanasius
in thread File existance check failure
by Festus Hagen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |