Apparently the fact that FindBin is utterly broken is still news to many people, because I see the following very often:
use FindBin;
use lib $FindBin::Bin;
This will put the directory from which the script was invoked into @INC. The right incantation for that is:
use File::Spec::Functions qw( catpath splitpath rel2abs );
use lib catpath( ( splitpath( rel2abs $0 ) )[ 0, 1 ] );
Yes, it’s quite a bit longer. However, it’s not broken, and in those cases in which it fails, it will fail reliably and comprehensibly, rather than doing bizarre bogus things as FindBin will.
Unfortunately not. (Score:2)
Re: (Score:1)
I can’t reproduce that.
Can you?
Re: (Score:2)
It's not just the longwinded bogus things it does (Score:2)
The reason for me was that FindBin just produced an error, in this case in a CGI script, because it had insufficient access rights to one of the ancestor directories (which is like a parent directory but possibly further upstream) of the directory that the script was in for some reason, FindBin seems to think it's necessary to walk the whole path.
So even though the script worked from the co
Re:It's not just the longwinded bogus things it do (Score:1)
Argh! That never occured to me – just another reason to steer clear. It’s almost comical how broken FindBin is if you get down to it – it’s almost a miracle how rarely people seem to be affected by that.
Have you filed a bug report (Score:1)
http://rt.cpan.org/Public/Dist/Display.html?Name=FindBin [cpan.org]
Re: (Score:1)
As I wrote in the comments of my other post about this [perl.org]:
And? (Score:1)
I think it is a bad precedence to suggest that we shouldn't document bugs because they have existed for a really long time and fixing them means deprecating the module entirely.
I am not trying to be flippant or antagonistic. I just think it is unfair to expect folks to have read everything you have read.
Re: (Score:1)
I am entirely fine with a doc patch for FindBin, and if there is a better module, a deprecation notice in the FindBin docs pointing to it. That’s not “fixing” FindBin, and therefore is a good idea. I hadn’t thought of that.
File::Spec::Functions fails, too (Score:1)
Re: (Score:1)
Yes, because it purposely does not examine the file system. This should work: