in reply to FindBin works differently on Fedora Core 2?

use File::Spec;

Either abandon FindBind entirely in favor of File::Spec, or just run the returned value through File::Spec->canonpath() and forget about it (or patch FindBin to do that automatically). canonpath should always eliminate a trailing dir separator if there is one.

update: For figuring out what's going on (if you still want to), use Devel::Trace;

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^2: FindBin works differently on Fedora Core 2?
by eserte (Deacon) on Jun 08, 2004 at 08:43 UTC
    I don't know of any File::Spec function which duplicates the FindBin behavior.

      Replace

      use FindBin qw($RealBin);

      with

      use File::Spec::Functions qw( rel2abs splitpath catpath ); my $RealBin = catpath( (splitpath rel2abs($0))[0,1] );

      or

      use File::Spec::Functions qw( rel2abs ); use File::Basename qw( dirname ); my $RealBin = dirname( rel2abs($0) );

      for example. And read how perverse FindBin is.

      - tye        

        Both solution give wrong results. Suppose /tmp/foo/abc.pl and a symlink from /tmp/abc.pl -> /tmp/foo/abc.pl. Changing cwd to /tmp and call ./abc.pl.
        • With the first version I get "/tmp/".
        • With the second version I get "/tmp".
        • With FindBin I get "/tmp/foo", as expected.
        Maybe you wanted to emulate $FindBin::Bin, not $FindBin::RealBin?

      I think PodMaster is suggesting sanitising the results of what FindBin returns with File::Spec, to obtain a canonical result, so to speak.

      - another intruder with the mooring of the heat of the Perl

        I would expect that FindBin itself returns a canonical result, as it always did.