Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Missing Module in CPAN

by Fletch (Bishop)
on Mar 05, 2022 at 03:56 UTC ( [id://11141847]=note: print w/replies, xml ) Need Help??


in reply to Re: Missing Module in CPAN
in thread Missing Module in CPAN

Was actually curious so went poking and I think it's a bug / mis-implemented feature that won't work as is now (presuming I'm reading the docs right and my empirical messing around was done correctly).

According to the documentation it's so that you can (paraphrasing) define class methods which will override the defaults for things like requires_firewall (which looks like the only specific method at any rate). But since the Net::Config would be a child of the putative Net::LocalCfg class then its (Net::Config) local version would override the parent's (Net::LocalCfg) implementation.

To do what it says on the tin you'd need to have your own subclass of Net::Config with the special behavior therein so that when you call the class method on that it'd do the right thing and find your custom overridden version.

My test local module is loaded, but as you can see the "override" isn't called.

$ cat foo/Net/LocalCfg.pm #!/usr/bin/env perl use 5.034; package Net::LocalCfg; BEGIN { say qq{## Loaded my LocalCfg}; } sub requires_firewall { my( $class ) = shift; say STDERR qq{## LocalCfg requires_firewall '$_[0]'}; return (rand() < 0.5) ? 1 : 0; } 1; __END__ $ perl -I ./foo -MNet::Config -E 'say Net::Config->requires_firewall( +q{google.com} )' ## Loaded my LocalCfg 0 $ perl -I ./foo -MNet::Config -E 'say Net::LocalCfg->requires_firewall +( q{google.com} )' ## Loaded my LocalCfg ## LocalCfg requires_firewall 'google.com' 0

The cake is a lie.
The cake is a lie.
The cake is a lie.

Log In?
Username:
Password:

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

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

    No recent polls found