Dear Monks,
I want to figure out when certain modules are being loaded, and for this reason, I want to override require. So far I've almost managed to achieve what I wanted. I've overridden require, and it is called. The problem is, that it's not called with the module actually required by the user. For instance, if I want to require Net::Ping, I will receive all of its requirements, but I will not receive it. Here is my test script, which illustrates the issue:
#!/usr/bin/perl
use strict;
*CORE::GLOBAL::require = sub {
CORE::require($_[0]);
print $_[0], "\n" if $_[0] eq 'Net/Ping.pm';
};
require Net::Ping;
my $p = Net::Ping->new;
What am I missing here? Also, if there's a better way of figuring out when modules are loaded (without having to modify the modules themselves), it would be a better solution.
-
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.
|