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

Try abs_path from Cwd.
  • Comment on Re^3: $Bin undef with FindBin in web environment

Replies are listed 'Best First'.
Re^4: $Bin undef with FindBin in web environment
by Anonymous Monk on Sep 01, 2004 at 14:53 UTC
    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"; } };