Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: File existence check failure

by Athanasius (Archbishop)
on Nov 11, 2012 at 04:11 UTC ( [id://1003297]=note: print w/replies, xml ) Need Help??


in reply to Re^2: File existance check failure
in thread File existance check failure

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

Replies are listed 'Best First'.
Re^4: File existence check failure
by Festus Hagen (Novice) on Nov 11, 2012 at 04:38 UTC
    Thanks,

    Awakens the the spacy name beast!

    Proto's ... geez my Cisims bite again. :)

    -Enjoy
    fh : )_~

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1003297]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found