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


In reply to can't understand the tie hash in tieregistry by anaconda_wly

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.