in reply to Re^3: adding library directories relative to $0
in thread adding library directories relative to $0

I hope not because switching from $0 to __FILE__ would not help resolve that problem at all. $0 eq __FILE__ in both runs.

In case you missed it, I brought up that problem and posted a solution to it earlier in the thread: swap the order of abs_path and dirname.

He's surely referring to adding to @INC in a file that's loaded using require or do.

Replies are listed 'Best First'.
Re^5: adding library directories relative to $0
by wind (Priest) on Feb 23, 2011 at 18:57 UTC
    ikegami,

    From what I remember, it was an issue for me only twice in the past.

    • 1) When running a system wide test harness on independent subsystem test scripts.
    • 2) While executing scripts using require or do like you stated above

    Anyway, both were very obscure cases that haven't come up again, and both could be worked around using alternative methods of course. Nevertheless, I still use the __FILE__ out of habit now.

Re^5: adding library directories relative to $0
by roboticus (Chancellor) on Feb 23, 2011 at 10:29 UTC

    ikegami:

    Gah! You're right. I should've spent the extra minute to try it with __FILE__ instead of $0. Oh, well, it can serve as yet another example of "test, don't assume!"

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.