I have script that makes heavy use of temp files, developed on a Perl 5.6.1 system. Not suprisingly, I use the File::Temp module to make life simpler and safer. Now I need to make things run on older systems (e.g., 5.005_03).
The first thing I need to do is add File::Temp to the older system, since it didn't become a core module until 5.6.1. I also need to add an updated version of File::Spec, since Perl 5.005_03 includes 0.6 and File::Temp wants 0.8. As I can't muck about with the system's Perl installation, I need to install these modules into a local directory I can access.
So my code looks something like this:
#!/usr/bin/perl -w use strict; use FindBin; use lib "$FindBin::Bin/../lib/perl"; use File::Temp qw(tempfile); # ... remainder snipped ...
Obviously, I've installed the modules into a "cousin" directory at the same level as the script, hence the use of FindBin. But when I run the script, it generates the following type of error:
File::Spec version 0.8 required--this is only version 0.6 at /wonko/sh +are/jwd/lib/perl/File/Temp.pm line 124. BEGIN failed--compilation aborted at /wonko/share/jwd/lib/perl/File/Te +mp.pm line 124. BEGIN failed--compilation aborted at ./foo line 34.
If I toss the "use FindBin;" statement and hardcode the "use lib ...;" statement to a particular path, then all is well. But unfortunately, as I can't predetermine where this will be installed, I really need the FindBin (or something like it).
What seems to be happening is that the system's default (0.6) version of File::Spec is being pulled in by the "use FindBin;" statement (I checked FindBin.pm and it does use File::Spec), effectively masking the local (0.8) version I've so carefully installed into my local "../lib/perl" directory.
So how do I get around this? Is there any method to force Perl to flush (or some such thing) all loaded modules after the "use lib ..." statement? Other alternatives? Setting the PERL5LIB environment variable before invoking the Perl script would work, I guess, but that's a bit much to ask in this environment.
In reply to Forcing use of newer (local) version of core module by jwd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |