Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^7: require() @INC hooks problem

by LanX (Saint)
on Dec 28, 2020 at 17:04 UTC ( [id://11125880]=note: print w/replies, xml ) Need Help??


in reply to Re^6: require() @INC hooks problem
in thread require() @INC hooks problem

fixed module template, less Perl version dependencies, more flexible and untangled templating

use strict; use warnings; use Data::Dumper; sub test_tmpl { my ($name) = @_; return $name, <<"__CODE__"; package $name; sub import { warn "$name imported"; } 1; __CODE__ } sub create_module { my ( $module, $source ) = @_; eval $source; (my $name = $module) =~ s(::)(\/)g; my @caller = caller(); $INC{"$name.pm"} = "imported via eval at @caller"; } BEGIN { create_module( test_tmpl('Jabba::Dabba') ); } use Jabba::Dabba; warn Dumper \%INC;

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125880]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-18 21:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found