HouZhe HouZhe - 13 days ago 5
Perl Question

Error of "encountered a second time" by find.pm

everyone,

when I deploy my package to a linux environment, I met this error:

.../Linux-2.6c2.5-i686/Ncurses/Ncurses-15766.0-0/lib/libncurses.so.5 is encountered a second time at /apollo/_env/FBAMerchantAutoRemovalDaemon-swit1na.1755067.237551097.1107633519/perl/lib/perl5.8-dist/File/Find.pm line 542.


though I read the
perl
script, I have no idea what is wrong. I suspect my environment is tainted. Does anyone have idea what is wrong and how can I debug this problem? Thanks a lot in advance!

Zhe

Answer

From perldoc File::Find

follow

Causes symbolic links to be followed. Since directory trees with symbolic links (followed) may contain files more than once and may even have cycles, a hash has to be built up with an entry for each file. This might be expensive both in space and time for a large directory tree. See "follow_fast" and "follow_skip" below. If either follow or follow_fast is in effect:

It is guaranteed that an lstat has been called before the user's wanted() function is called. This enables fast file checks involving _. Note that this guarantee no longer holds if follow or follow_fast are not set.

There is a variable $File::Find::fullname which holds the absolute pathname of the file with all symbolic links resolved. If the link is a dangling symbolic link, then fullname will be set to undef.

So, if, for the purposes of your application, if it is OK to follow symlinks, invoke find with the follow option set:

find({ wanted => \&process, follow => 1 }, $dir);

Or, consider if one of the other follow_skip behaviors is more appropriate for your application:

follow_skip

follow_skip==1, which is the default, causes all files which are neither directories nor symbolic links to be ignored if they are about to be processed a second time. If a directory or a symbolic link are about to be processed a second time, File::Find dies.

follow_skip==0 causes File::Find to die if any file is about to be processed a second time.

follow_skip==2 causes File::Find to ignore any duplicate files and directories but to proceed normally otherwise.

It may be that follow_skip => 2 is more appropriate for your application. Only you can make that decision.

Comments