in reply to •Re: Adding script location to include path
in thread Adding script location to include path

I was referring to FindBin itself, which uses the same libs as the snippet (File::Spec, and File::Basename), and brings in Cwd, Carp, and Config as well. It's not much more (and most likely already loaded by other things anyway) but uneeded in this particular case. :)

Whichever's easier for you. Either way works fine (at least I think it does.. haven't extensively tested every scenario), and comes in handy.
  • Comment on Re: •Re: Adding script location to include path

Replies are listed 'Best First'.
•Re: Re: •Re: Adding script location to include path
by merlyn (Sage) on Jul 11, 2003 at 14:44 UTC
    But your code also in turn pulls in those libs! Let's experiment:
    $ cat <<END >in-yours use File::Spec; use File::Basename; use lib &dirname(File::Spec->rel2abs($0)); print "$_\n" for sort keys %INC; END $ perl in-yours >out-yours $ cat <<END >in-mine use FindBin qw($Bin); use lib $Bin; print "$_\n" for sort keys %INC; END $ perl in-mine >out-mine $ comm out-yours out-mine Carp.pm Config.pm Cwd.pm Exporter.pm Exporter/Heavy.pm File/Basename.pm File/Spec.pm File/Spec/Unix.pm FindBin.pm XSLoader.pm attributes.pm base.pm lib.pm re.pm strict.pm vars.pm warnings.pm warnings/register.pm $
    So, the only differences are FindBin itself and Exporter::Heavy. Your attempt to avoid Cwd, Carp, and Config are not avoided in the slightest.

    So please, don't try to reinvent the wheel until you know what that wheel is doing.

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