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

I am using the Tie::Registry module and have a question.

If I want to get a registry value I am using this format

$a=$Registry->{CUser}->{xxx}->{yyy}->{zzz}->{value}

What I end up doing is creating keys of say yyy because that key didn't exist on a particular system. If there a way to check for a value without creating keys short of walking down the registry?

The opposite question is about adding a value to the registry. I'd like to do

$Registry->{CUser}->{xxx}->{yyy}->{zzz}->{value} = "data"

But it fails and creates the first missing level. I have had to walk down checking each level to make this work.

I hope I am not seeing something in the documentation that someone can point out.

Replies are listed 'Best First'.
Re: Tie::Registry add/check values (ex)
by tye (Sage) on Aug 13, 2010 at 03:53 UTC
    use Win32::TieRegistry( TiedRef => \my $Reg, Delimiter => '/', ); if( ! $Reg->('CUser/xxx/yyy/zzz//value'} ) { $Reg->{'CUser/xxx/'}= { yyy => { zzz => { '/value' => 'data' } } }; }

    Or roughly so. Read near similar examples in the documentation for more information.

    - tye        

Re: Tie::Registry add/check values
by ikegami (Patriarch) on Aug 13, 2010 at 02:37 UTC
      Sorry, I am using the Win32::Tie::Registry
        I mean Win32::TieRegistry