Beefy Boxes and Bandwidth Generously Provided by pair Networks chromatic writing perl on a camel
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

can't understand the tie hash in tieregistry

by anaconda_wly (Scribe)
on Jan 07, 2013 at 10:05 UTC ( #1012009=perlquestion: print w/ replies, xml ) Need Help??
anaconda_wly has asked for the wisdom of the Perl Monks concerning the following question:

I'm reading Win32::TieRegistry.pm and can't understand the relation between $RegObj and $Registry by code. Is anyone willing to help me? Thanks in advance! As code snippet below

$RegObj->Tie( \%RegHash ); $Registry= \%RegHash; bless $Registry;

I can understand $RegObj is a blessed object holding something like the access options. $Registry is blessed into the same package and a ref to %RegHash, the virtual root of the registry tree stored as a hash.

My first question is: As I didn't understand Tie clearly, How $RegObj and $Registry affect to each other after Tied?

My second quetion is I didn't know how the %RegHash got its contents regarding the default setting in $RegObj?

As when using, we only need to "use Win32::TieRegistry", then use $Registry->{$myKey} will return the registry hash I want, too simple to understand. No "new" call to load from registry.

I read the author override the import function in EXPORT to support a user-defined options. If I want to add another default $RegObj2 and $Registry2, how can I make it through just after "use" and can then get $Registry2 filled? I don't know if I state my problem clear....Sorry seems too long.

OK, I understand some now. The TieHash in TieRegistry is auto called by Perl when tying and called sub new. $Registry(\%RegHash) is used by user like a real hash and will call the underlaid TieRegistry method with blessed $RegObj(since tied).

Comment on can't understand the tie hash in tieregistry
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1012009]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-04-19 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls