Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Yes, this is possible, but also, that way lies madness. If you go down that road, you will make things much harder for you, and you will have to debug lots of weird errors. You are much better served by re-installing a fresh copy of all modules with your current Perl, and keeping your modules (say) in a cpanfile so you can reinstall them quickly whenever you move to a new version.

Perl will not reload a module if it has already been loaded. A first, horrible approach is to manually pre-load all the modules you want from the appropriate directories:

use 5.020; use feature 'experimental::signatures'; no warnings 'experimental::signatures'; sub preload_module( $base_dir, $modulename ) { my $final_name = $modulename; $final_name =~ s!::!/!g; require "$base_dir/$final_name.pm"; } BEGIN { preload_module('/some/perl5/dir', 'List::Util' ); preload_module('/some/perl5/dir', 'Scalar::Util' ); preload_module('/some/other/perl5/dir', 'Another::Module' ); } use List::Util 'reduce';

An even more horrible way is to set up a hook in @INC which looks at the file to be loaded and chooses the correct one:

use 5.020; use feature 'experimental::signatures'; no warnings 'experimental::signatures'; my %module_map = ( 'List/Util.pm' => '/some/path/to/perl/modules', 'Scalar/Util.pm' => '/some/other/path/to/perl/modules', ); sub find_correct_module( $self, $module_file ) { my $real_module = $module_map{ $module_file } // $module_file; open my $fh, '<', $real_module or croak $!; return $fh } BEGIN { unshift @INC, \&find_correct_module; }

This will be even harder to debug but allows you to have deep dependencies automatically resolved without preloading modules.

Again, my advice is to do a fresh start and keep a list of all modules you need, and use local::lib and to install all dependencies below a directory separate from the system Perl directory.


In reply to Re^6: help with "symbol lookup error" message by Corion
in thread help with "symbol lookup error" message by Special_K

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-25 13:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found