Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^3: File::Find preprocess

by pvaldes (Chaplain)
on Jan 08, 2018 at 17:13 UTC ( [id://1206923] : note . print w/replies, xml ) Need Help??

in reply to Re^2: File::Find preprocess
in thread File::Find preprocess

Hum, I see. I was expecting an equivalent to the "previously" condition in a common-lisp loop structure. A chunk of code that happens only once before the main body of the function starts iterating. I understand that if I need to do something within each subdirectory (check if something happens inside each subdir first), I would need then to traverse the tree two times using two different find functions. One for directories only, and a second for all files. Right? can't be done in one take?

Replies are listed 'Best First'.
Re^4: File::Find preprocess
by stevieb (Canon) on Jan 08, 2018 at 17:20 UTC

    I'm a bit unclear exactly what you're asking, but if you want to do something for files and something different for directories:

    sub wanted { if (-d){ print "directory\n"; } if (-f){ print "file\n"; } }

      Mmmh. Could work, I'll try this and see what happens. Thanks