Hi, welcome to the Monastery,
That tutorial, while still probably valid, is almost 20 years old. File::Find is still the core Perl module, but there are modern wrappers to make life easier.
See Path::Tiny which is modern Perl's basic file-handling tool, and which includes an iterator() method as well as a wrapper around that (visit()) which takes a callback to be executed on every file found.
You didn't show an example of your File::Find code, but I'd rather steer you towards a modern tool anyway, so here's a demo:
$ ls -d vskatusa/*/*/*
vskatusa/blarg/blorg/blech vskatusa/foo/bar/baz
$ perl -Mstrict -MPath::Tiny -wE 'say for path("vskatusa")->children'
vskatusa/blarg
vskatusa/foo
$ echo 'frooble' > vskatusa/textfile
$ perl -Mstrict -MPath::Tiny -wE 'say for path("vskatusa")->children'
vskatusa/blarg
vskatusa/textfile
vskatusa/foo
$ perl -Mstrict -MPath::Tiny -wE 'path("vskatusa")->visit(sub { say if
+ $_->is_dir });'
vskatusa/blarg
vskatusa/foo
For more complex file-finding use cases (which yours is not), see Path::Iterator::Rule by the same author.
Hope this helps!
The way forward always starts with a minimal test.
|