in reply to Re: How To Get The File's Directory?
in thread How To Get The File's Directory?

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.

Replies are listed 'Best First'.
Re^3: How To Get The File's Directory?
by Anonymous Monk on Nov 19, 2009 at 15:38 UTC
    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!
Re^3: How To Get The File's Directory?
by Anonymous Monk on Nov 19, 2009 at 15:30 UTC
    Time for a __DIR__ token?