in reply to Perl with Windows Registry
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...
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.foreach $k (keys %vals) { $key = $vals{$k}; } $CurrVer->SetValue("",REG_SZ, "$pathe"); foreach $k (keys %vals) { $key = $vals{$k}; print "$$key[2]\n"; }
Example
gives#!/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";
How this affects the statement$key=two $key=five
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??$CurrVer->SetValue("",REG_SZ, "$pathe");
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 |