Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Changing package variable via object-instance

by liz (Monsignor)
on Aug 25, 2003 at 17:48 UTC ( #286436=note: print w/replies, xml ) Need Help??


in reply to Changing package variable via object-instance

I can't see anything blatantly wrong. But looking at your node, several questions come up:
Why not make %config set inside _fill_config?
If the only way to set %config is by calling _fill_config, why don't you set %config directly in there?

Are you using AutoLoader/SelfLoader/load?
If you are, and _change_config/_fill_config are in the area that's not always loaded, they will not see the "same" package lexical (it will be a package global to them).

Why the flattening?
You realize of course that if you're returning a hash, you're essentially flattening it to a list and return that. From an effieciency point of view, it's much better to return a reference to a hash (and probably have the package lexical $config be a reference as well).

Are you sure _parse_file works ok?
Double check in _fill_config that actually the thing you expect, is being returned.

I think there are other things going on in your example that I find strange. But for now I'll attribute those to the making of the (pseudo) takeout.

Hope this helps

Liz

  • Comment on Re: Changing package variable via object-instance

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2022-09-25 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (116 votes). Check out past polls.

    Notices?