in reply to Perl with Windows Registry

Warning: I know nothing about Win32::Registry, but nonetheless, I tried to see if I could learn something from your post.

There are 4 bits of code that are repeated over. Maybe a loop over your various definitions of $p might be in order.

But this bit of code definately confuses me...

foreach $k (keys %vals) { $key = $vals{$k}; } $CurrVer->SetValue("",REG_SZ, "$pathe"); foreach $k (keys %vals) { $key = $vals{$k}; print "$$key[2]\n"; }
Near as I can figure, the 1st foreach loop ends up setting the $key scalar to one of the values in the hash, with no knowledge of what the key ($k) / value ($key) combination is. Note that the manual clearly states that (keys %myhash) returns the keys in a pseudo-random order.

Example

#!/usr/bin/perl # arbitray hash table my %vals = ("1","one","2","two","3","three"); # your code foreach $k (keys %vals) { $key = $vals{$k}; } print "\$key=$key\n"; # add something else to hash table %vals = ("1","one","2","two","3","three","4","four","5","five"); # your code foreach $k (keys %vals) { $key = $vals{$k}; } print "\$key=$key\n";
gives
$key=two $key=five
How this affects the statement
$CurrVer->SetValue("",REG_SZ, "$pathe");
I have no idea, because as I said before, I am not familiar with the windows registry module. But how is $key known by the SetValue function? Is it a global variable??

Sorry not to be of more help, but maybe some of this might help you figure out what your program is really doing, and what it is you want it to do.

Replies are listed 'Best First'.
Re: Re: Perl with Windows Registry
by jbrown (Initiate) on May 26, 2004 at 13:23 UTC
    Thankyou Sandy for your quick reply.

    I think you found out what my problem was. Although I have not yet fixed it.
    As for this line:

    $CurrVer->SetValue("",REG_SZ, "$pathe");

    It writes the value $pathe to a registry key.

    Thankyou again for your help. I will keep everyone posted on my progress.

    Joshua.