in reply to Re: $Bin undef with FindBin in web environment
in thread $Bin undef with FindBin in web environment

Thank you. This almost does what I want. Unfortunately, the result contains a symbolic link and I would like to know where the file actually is. I read the perldoc for File::Spec but did not find anything that would solve my problem.

Would you happen to know of a function which does that?

  • Comment on Re^2: $Bin undef with FindBin in web environment

Replies are listed 'Best First'.
Re^3: $Bin undef with FindBin in web environment
by eserte (Deacon) on Sep 01, 2004 at 12:44 UTC
    Try abs_path from Cwd.
      Thank you. The two together correctly calculate the script's path dynamically.

      For future reference for anyone who may need it, the entire section of code I'm using to determine the location of lib, where I have a directory structure like 'client/project/*' (where I have bin, cgi and lib at the * level and want my local lib first is:

      BEGIN { use Cwd qw/abs_path/; use File::Spec::Functions qw/rel2abs/; my $path = rel2abs(abs_path($0)); if ($path =~ m,^((?:/\w+)*?/)(?:cgi|bin)/,) { unshift @INC, $1.'lib'; } else { die "Unable to determine lib path from $path"; } };