Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: MIME::Lite not respecting my decisions

by skazat (Chaplain)
on Mar 05, 2002 at 03:04 UTC ( [id://149272]=note: print w/replies, xml ) Need Help??


in reply to Re: MIME::Lite not respecting my decisions
in thread MIME::Lite not respecting my decisions

So there's no way to change the value of a public and documented variable if I use 'require'? I find that very hard to believe. In the module, it's not exported, I wonder why the author set it up this way, instead of providing a method for this?

weird

 

-justin simoni
!skazat!

  • Comment on Re: Re: MIME::Lite not respecting my decisions

Replies are listed 'Best First'.
(Zaxo) Re x3: MIME::Lite not respecting my decisions
by Zaxo (Archbishop) on Mar 05, 2002 at 07:26 UTC

    Generalities first: sure you can, but it may not have the same effect. If the module has an import sub, require does not call it. If the variable is used in a closure, that closure will freeze a default or undef at compile time and never see the change. It's all a matter of how the module is designed.

    The MIME::Lite source shows $PARANOID used in the initialization of the file-scoped lexical @Uses at the module's runtime. Paraphrasing:

    if (!PARANOID) { push @Uses, $type; }
    Now subs will look to the symbol table for the value of a package global but, if I understand this correctly, the @Uses array is populated once when the module's runtime happens. @Uses depends only on the value of $PARANOID at that time. Reetting $PARANOID later has no effect, as you observed. This is independent of use vs. require. It could be made possible to do this:
    package MIME::Lite; our $PARANOID = 1; # doesn't work package main; require MIME:Lite;
    but that doesn't work because MIME::Lite assigns $PARANOID its default unconditionally (the ||= operator comes to mind here). A redesign of paranoia and type import is needed to get fully featured runtime switching between paranoid and trustful states. So, yes, your problem does appear to be a bug.

    The short version is that you must either edit MIME::Lite to set $PARANOID = 1, or else install the extra modules.

    It's a different story for your own subs which need the module. If their dependencies are not satisfied until a second round of compilation within runtime, the optimization stage will have to work with much less information, and many foldings will be lost, much unneeded bytecode carried around.

    Why do you want to require a module at runtime? If it's for economy, inside a conditional, it may be a false economy.

    After Compline,
    Zaxo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-26 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found