Both solutions are unreliable in some cases: The one with Class::Path relies on the assumption that no chdir has happened so far (which is reasonable at the top of a file, but not otherwise), and $0 is very platform specific.
(I don't want to critique them, just point to potential problems)
Other methods include FindBin in scripts and looking in %INC in modules. I'm sure both can be fooled too, though. | [reply] |
Hi guys, thanks for the replies... Actually, $0 solves the problem, it always gives "c:/temp/temp.pl", regardless of where I run the scripts.
I've tried running this scripts from various different directories, and I find that the only exception being, when I run it from "c:/temp/", then it'll give only "temp.pl", without any directory. Simply work around this exception will solve my problem at the moment.
At this moment, I'm only working on the Windows platform, so I'll be safe, for now. :)
Again, thanks a bunch, really appreciate it, guys!
| [reply] |
Time for a __DIR__ token?
| [reply] |