File::Find - following s'linked directories?

P

Peter Ensch

It's been a while since I used File::Find and I was under the impression
that it now supported traversal of symbolically linked directories; the
POD indicates that this is the case in the following warning:

"Be aware that the option to follow symbolic links can be dangerous.
Depending on the structure of the directory tree (including symbolic links
to directories) you..."

I cannot seem to make F::F follow links to directories however. Using
find2perl to generate an example script from this find command:

find2perl /an/example/dir/tree -follow -print

I get this (comments, shebang Etc. removed):

###########
use File::Find ();

use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;

sub wanted;

File::Find::find( {wanted => \&wanted, follow => 1},
'/an/example/dir/tree');
exit;

sub wanted {
print("$name\n");
}
###########

Why doesn't this follow symbolically linked directories like the
unix find command used to create it does?

Thanks,
Peter


--

^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
Peter Ensch,
(e-mail address removed) A-1140 (214) 480 2333
^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^
 
J

Josef Moellers

Peter said:
It's been a while since I used File::Find and I was under the impression
that it now supported traversal of symbolically linked directories; the
POD indicates that this is the case in the following warning:

"Be aware that the option to follow symbolic links can be dangerous.
Depending on the structure of the directory tree (including symbolic links
to directories) you..."

I cannot seem to make F::F follow links to directories however. Using
find2perl to generate an example script from this find command:

find2perl /an/example/dir/tree -follow -print

I get this (comments, shebang Etc. removed):

###########
use File::Find ();

use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;

sub wanted;

File::Find::find( {wanted => \&wanted, follow => 1},
'/an/example/dir/tree');
exit;

sub wanted {
print("$name\n");
}
###########

Why doesn't this follow symbolically linked directories like the
unix find command used to create it does?

Must be something else, caus on my box it does (follows if follow => 1,
does not follow if follow => 0).
 
J

Joe Smith

Peter said:
Why doesn't this follow symbolically linked directories like the
unix find command used to create it does?

The Unix 'find' command does not follow symbolically linked
directories unless "-follow" is explicitly requested.
File::Find has a similar feature, but also has to be
explicitly requested.

-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top