Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Reloading modules- suppressing warnings works sometimes?

by liz (Monsignor)
on Dec 20, 2003 at 23:54 UTC ( [id://316114]=note: print w/replies, xml ) Need Help??


in reply to Reloading modules- suppressing warnings works sometimes?

Could it be that the modules that you are reloading, contain a use warnings; themselves, which would override the no warnings 'redefine'; inside the eval?

If that's the case, I wouldn't know of a simple solution to this problem, other than reading the contents of the file to be required into a variable (e.g. $source) and then doing a:

$source =~ s#(use warnings[^;]*)#$1;no warnings 'redefine'#sg; eval $source;

This is pretty yucky, though. And may fail when the required file itself uses or requires other files.

I guess more rigorous methods such as adding a subroutine handler to @INC or stealing CORE::require would be methods for handling this reliably.

Or maybe simplify matters by installing a __WARN__ handler that would filter out the redefined warnings?

Hope this helps.

Liz

Replies are listed 'Best First'.
Re: Re: Reloading modules- suppressing warnings works sometimes?
by JPaul (Hermit) on Dec 21, 2003 at 05:17 UTC
    If this was the case, then foo would not reload without warnings :)
    Still, good thoughts.

    JP,
    -- Alexander Widdlemouse undid his bellybutton and his bum dropped off --

Log In?
Username:
Password:

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

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

    No recent polls found