perl - How to handle File::Find on Windows with long paths -


i've been trying use perl's file:find recursively find files on windows system drive. unfortunately errors out during execution long file path. know how handle in way such script can continue running , let me know paths had skip. can count files until encounters path doesn't like, @ point stops.

what basing off: http://www.perlmonks.org/?node_id=217166 found following article, similar problem, unable apply it: http://www.perlmonks.org/?node_id=933849

#/usr/bin/perl use strict; use file::find;     $superfilecount = 0; # first try find(\&print_name_if_dir, no_chdir=>1, ".");  # second try eval { find(\&print_name, no_chdir=>1, ".") }; warn $@ if $@; # end of second try  sub print_name {         $superfilecount++; } print "all files found: $superfilecount \n"; 

first run:

can't cd ../../../../../../../../../.. ./users/username/appdata/roaming/ macromedia/flash player/#sharedobjects/8z5rpfsr/foxnewsplayer-a.akamaihd.net/[[i mport]]/players.edgesuite.net/flash/plugins/osmf/advanced-streaming-plugin/v3.6/ osmf2.0/akamaiadvancedstreamingplugin.swf: no such file or directory @ c:/straw berryperl/perl/lib/file/find.pm line 812. 

if wrap in eval, partial filecount lower on drive:

can't cd ../../../../../../../../../.. ./users/username/appdata/roaming/ macromedia/flash player/#sharedobjects/8z5rpfsr/foxnewsplayer-a.akamaihd.net/[[i mport]]/players.edgesuite.net/flash/plugins/osmf/advanced-streaming-plugin/v3.6/ osmf2.0/akamaiadvancedstreamingplugin.swf: no such file or directory @ c:/straw berryperl/perl/lib/file/find.pm line 812. files found: 84730 

if want use no_chdir parameter (or parameter matter), need enclose params in hash reference. you're not, why no_chdir isn't taking effect. try this:

find({ wanted => \&print_name, no_chdir => 1 }, '.'); 

i don't know if fix problem, actual path isn't being processed properly, , may not have doing cd.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -