in reply to $Bin undef with FindBin in web environment

Note that FindBin is broken. As that node mentions, you want something like

use File::Spec::Functions qw( rel2abs ); print "I am ", rel2abs( $0 ), "\n";

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^2: $Bin undef with FindBin in web environment
by Anonymous Monk on Sep 01, 2004 at 12:08 UTC
    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?

      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"; } };