From: Smylers Date: 22:00 on 08 Sep 2005 Subject: Perl FindBin Module Perl comes with a module called FindBin, which generally finds the directory in which the currently executing script is located. It comes with this caveat: If there are two modules using FindBin from different directories under the same interpreter, this won't work. Since FindBin uses a BEGIN block, it'll be executed only once, and only the first caller will get it right. This is a problem under mod_perl and other persistent Perl environments, where you shouldn't use this module. That's fair enough -- if I use FindBin in mod_perl, the directory it provides may not be what I want. What it doesn't say is that if under mod_perl I use a module which in turn loads FindBin, that will make 'Apache' non-deterministic, such that I will spend over 3 hours wondering why sometimes my code just fails with a 500 message to the browser yet nothing at all in the 'Apache' error log; sometimes it fails with a 500 and a log message about not being able to find a method that blatantly does exist; and sometimes it manages to find an execute the method but does the wrong thing because a package variable in the module that loaded FindBin is mysteriously empty.[*0] All this just from _loading_ FindBin! I'm not even giving it a chance to return the wrong directory because the module that loads FindBin only uses it in one method, and I'm not calling that method. Hate Hate-Hate-Hate HateHateHate hatehatehatehatehatehatehatehatehate. And while I'm here, can I also hate 'OTRS', a ticketing system which runs under mod_perl yet tries to make use of FindBin anyway, despite its being documented as not working (and talking of not working, the 'OTRS' website has been down for at least the past several hours, so I can't even channel my hate into a patch or bug report) in that environment. This conveniently allows 'OTRS' to surprise you by suddenly breaking at a moment when you weren't anywhere near it. [*0] Also sometimes it appears to fail by completely locking the server such that it needs power-cycling to do anything. But our sys-admin's current hunch is that was caused by dodgy memory, so I'm excluding that from the hate at the moment. Smylers
Generated at 10:27 on 16 Apr 2008 by mariachi