in reply to Directory in which your program is running...

It's not clear to me whether you mean the directory in which the program is located, or the current directory of the process that invoked the program, or the current directory of the process as possibly modified by calls to chdir. Those are three entirely different things. You can get the first using FindBin, and the last by Cwd, but the middle one you have to do early enough in the program. {grin}

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on •Re: Directory in which your program is running...

Replies are listed 'Best First'.
Re: •Re: Directory in which your program is running...
by theguvnor (Chaplain) on Jan 26, 2003 at 18:21 UTC

    Oops. I should have specified: the directory in which the program is located; which should be the same as the directory of the process since I'm not using any chdir calls.

    Thanks,

    Jon

    Update: further clarification per Merlyn's advice below: I will only be running the scripts from the directory they are in.

      Oops. I should have specified: the directory in which the program is located; which should be the same as the directory of the process since I'm not using any chdir calls.
      No, that's precisely the thinking that will get you into trouble, which is why I asked the question I did.

      When I invoke "some/path/to/script", my current directory hasn't changed, but the script is located in some other directory. So I wanted to know which of the two you wanted: the current directory, or the directory of the script.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

      Another way to do it:
      use File::Basename; my $dir = dirname $0;
      Or, if you are *sure* that you will only be running the scripts from the directory that they are in, you can specify relative paths starting from ".".

        Thanks - I eventually did use relative paths. I am sure to only be running the scripts from the directory in which they reside. I'm a team of 1, just with a couple/three machines I flop back and forth on. : )

        Jon