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

How can you create a string value in the registry with using W32::Registry.

Replies are listed 'Best First'.
Re: Registry String Values
by ikegami (Patriarch) on Apr 07, 2005 at 19:21 UTC
    I presume you mean Win32::Registry. According to the first line of that module's documentation, it's obsolete. Win32::TieRegistry is recommended as an alternative. Here's an example using Win32::TieRegistry:
    use Win32::TieRegistry; $Registry->{"LMachine/Software/MyCompany/MyProduct/$key"} = $strval; #or $Registry->{"LMachine/Software/MyCompany/MyProduct/"}{$key} = $strval;
Re: Registry String Values
by NetWallah (Canon) on Apr 08, 2005 at 04:53 UTC
    Setting values while creating sub-keys requires somewhat convoluted syntax, but is documented.
    use Win32::TieRegistry(Delimiter=>'/'); my $ms= $Registry->{'LMachine/Software/Microsoft/'}; $ms->{'Junk1/'} = { 'Junk2/'=> {'/Junk3' => ['JunkVal','REG_SZ']} + };
    This (tested) code will create the Junk1 key under Microsoft. Under that, under subkey Junk2, you will find the Name Junk3, which will contain the value "JunkVal".

         "There are only two truly infinite things. The universe and stupidity, and I'm not too sure about the universe"- Albert Einstein

      Thanks, that worked great. I have everything in my searchlist that I needed.
Re: Registry String Values
by NateTut (Deacon) on Apr 07, 2005 at 19:49 UTC
    Ditto ikegami's reply. Win32::TieRegistry is great, it makes the Registry work just like a hash. So creating a new value is just like creating a new hash entry.
      I tried it and then went and looked in the registry and it was not there.
        Have you created the "upper levels" first? You might want to post your code too...