Marza has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I am probably making more of this then it is but is it better to use:
$ver=$Registry->{"//$_/HKEY_LOCAL_MACHINE/Software/Network Associates/ +TVD/NetShield NT/CurrentVersion//szProductVer"}
or the connect option with:
$key = $Registry->Connect("$computer","LMachine/Software/Network Assoc +iates/TVD/NetShield NT/CurrentVersion" {Access=>KEY_READ} ) ) $ver = $key->GetValue("szProductVer")
In terms of the current script, there are not that many machines so there is no noticible difference. Am I making something of nothing?

Replies are listed 'Best First'.
Re: TieRegistry etiquette/performance question.
by Necos (Friar) on Mar 19, 2002 at 23:03 UTC
    If you have to open a lot of registry keys, it's better to connect to the root, then connect to the individual keys. It will save you a LOT of typing. Otherwise, I do not believe there is a performance difference.

    Theodore Charles III
    Network Administrator
    Los Angeles Senior High
    4650 W. Olympic Blvd.
    Los Angeles, CA 90019
    323-937-3210 ext. 224
    email->secon_kun@hotmail.com
      Thank you and that is how I will use it.
(tye)Re: TieRegistry etiquette/performance question.
by tye (Sage) on Mar 20, 2002 at 21:13 UTC

    The big difference is that {Access=>KEY_READ} means that you don't have to have KEY_WRITE access to all of the registry keys involved.

    If you access multiple items from the same machine, then it is best (more efficient, much faster in the face of failures) to open some key that is above all of the items to be checked (perhaps just "//$computer/"). But I see no advantage at all to using GetValue() (that'd simply be a style issue).

            - tye (but my friends call me "Tye")