in reply to Forcing use of newer (local) version of core module

Start your program with something like:
#!/opt/perl/bin/perl -w use strict; use warnings; use FindBin; BEGIN { delete $INC {'File/Spec.pm'}; delete $INC {'File/Spec/Unix.pm'}; } use vars '$old_W'; BEGIN {$old_W = $^W; $^W = 0} use libs '....'; # The 'cousin' directory here. use File::Spec; BEGIN {$^W = $old_W}
File::Spec might pull in something else on a different OS. Experiment. The key thing here is the deletion from %INC, which if we leave %INC as it is, will prevent use and require from recompiling a module.

Note that you'll get warnings if File::Spec would do a use warnings.

-- Abigail

Replies are listed 'Best First'.
Re: Forcing use of newer (local) version of core module
by Anonymous Monk on Jul 06, 2001 at 04:30 UTC

    Abigail's solution works -- mostly.

    I had to toss the use warnings; pragma, as the module isn't included in Perl 5.005_03.

    The situation now stands as follows:

    • On a 5.005_03 installation, the script runs to completion with no nasty messages.
    • On a 5.6.0 installation, the script yields this warning message:
      Prototype mismatch: sub File::Spec::Unix::rel2abs ($;$;) vs none at /w +onko/share/jwd/lib/perl/File/Spec/Unix.pm line 447.
    Any suggestion as to how to eliminate this? Explanation as to its cause? The mucking about with $^W nukes all the other warnings, save this one.

    FWIW, I didn't really get your closing remark " Note that you'll get warnings if File::Spec would do a use warnings." Care to elaborate?