Tue Nov 01 18:11:09 2011: Request 72082 was acted upon. Transaction: Correspondence added by RSCHUPP Queue: Module-ScanDeps Subject: $FindBin::Bin issue on Moudel::ScanDeps 1.04 Broken in: (no value) Severity: (no value) Owner: RSCHUPP Requestors: mdengf...@gmail.com Status: open Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=72082 >
OK, I see what's happening: When you call scandeps.pl with option -c (or -x) it creates a temporary file that contains the text of the file to scan plus some prologue code. This prologue code will be called at the end of compilation (-c) or execution (-x) and just dumps the contents of %INC, $INC etc. scandeps.pl runs an inferior perl on this temporary file and reads back the information. This temporary file used to be created in your working directory, so if your script is also located there, FindBin for your script and for the temp file would come to the same result. In 1.04 I changed it so that the temp file is created in your platform's temp directory. That explains why you see /tmp/lib in @INC in the error message. Can you try the attached patch? It makes FindBin return the correct result by setting $0 to the path of your script. Cheers, Roderich
Index: lib/Module/ScanDeps.pm =================================================================== --- lib/Module/ScanDeps.pm (revision 1285) +++ lib/Module/ScanDeps.pm (working copy) @@ -1241,14 +1241,23 @@ my ($feed_fh, $feed_file) = File::Temp::tempfile(); my $dump_file = "$feed_file.out"; + require Data::Dumper; + + # fake $0 (to $file) so that FindBin works as expected + # NOTE: We don't directly assign to $0 as it has magic (that may + # fail, cf. perlvar(1)), instead we alias *0 to a package variable + # holding the correct value. + print $feed_fh "BEGIN { ", + Data::Dumper->Dump([ $file ], [ "Module::ScanDeps::DataFeed::_0" ]), + "*0 = \\\$Module::ScanDeps::DataFeed::_0; }\n"; + print $feed_fh $do_compile ? "INIT {\n" : "END {\n"; # NOTE: When compiling the block will run _after_ all CHECK blocks # (but _before_ the first INIT block) and will terminate the program. # When executing the block will run as the first END block and # the programs continues. - # correctly escape filenames - require Data::Dumper; + # correctly escape strings containing filenames print $feed_fh map { "my $_" } Data::Dumper->Dump( [ $INC{"Module/ScanDeps/DataFeed.pm"}, $dump_file ], [ qw( datafeedpm dump_file ) ]);