Hi Harry!
On Fri, 23 Jun 2017 16:56:13 -0400
Harry Putnam <[email protected]> wrote:
> Trying for a better understand of using File::Find, butI'm missing
> something pretty basic I think
>
> First: The directory structure in this test:
>
> ./one/tst.pl
> two/tst.pl
> three/tst.pl
>
> So each directory in the layering has the same type -f file in it.
>
> Or
> ls -R ./one
> ./one:
> tst.pl two
>
> ./one/two:
> three tst.pl
>
> ./one/two/three:
> tst.pl
>
> I'm sure its something in my formulation (in other words, pilot
> shooting self in foot) but; This bit of code seems not to do what one
> would expect:
>
> ------- ------- ---=--- ------- -------
>
> use strict;
> use warnings;
> use File::Find;
>
> my $d = './one';
>
> find sub {
> return if -f;
> print "\$File::Find::dir<$File::Find::dir>\n";
> }, $d;
>
> ------- ------- ---=--- ------- -------
>
> Output:
> reader > ./tst.pl
> $File::Find::dir<./one>
> $File::Find::dir<./one>
> $File::Find::dir<./one/two>
>
$File::Find::dir is the containing directory of the path item (= the dirname in
http://perldoc.perl.org/File/Basename.html ). Finally, note that File::Find has
some severe philosophical limitations, and you should look into alternatives on
CPAN such as https://metacpan.org/pod/File::Find::Object (which I happen to
maintain) or https://metacpan.org/pod/Path::Iterator::Rule#SEE-ALSO . For more
about that, see:
http://shlomif-tech.livejournal.com/29315.html
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html
Trying to block Internet pornography is like climbing a waterfall and trying
to stay dry. (— one of Shlomi Fish’s Internet Friends)
— http://www.shlomifish.org/humour.html
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/