Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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 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).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1012009]
Approved by davido
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2018-04-21 16:11 GMT
Find Nodes?
    Voting Booth?