Hi all.

I have a large bit of code that I have been
maintaining for several years.  I ran into a problem a
couple of weeks back where I made a change to the code
and I ended up deleting a registry key structure on a
lot of machines.  I was Mr Popular for a while there..
Anyway I've managed to reproduce the problem in a few
lines of code show below (there are not too many lines
so hopefully line wrapping won't be a problem:
* * * BEGIN CODE  * * *
use Win32::TieRegistry( Delimiter=>"#" );

$nodename = $ENV{COMPUTERNAME};
$Register7 =
"SYSTEM#CurrentControlSet#Services#Tcpip#Parameters";
if ($hkey_connect = $Registry->Connect($nodename,
"LMachine#", {Access=>KEY_READ})) {
        $dns_interfaces_hash =
$hkey_connect->{"$Register7#Interfaces2#"};
# # do something with the data in this hash
}
# # # This deletes the above 'Interfaces2' key
structure.  Why?
undef %$dns_interfaces_hash;
* * * END CODE  * * *

The 'Interfaces2' does not exist natively on a system
I copied the 'Interfaces' key structure so that I
could play around with a non-critical key structure.

What I meant to do was put:
undef $dns_interfaces_hash;
on the last line instead of what is there.

My question is if I have specified that I connect to
the registry in KEY_READ mode how is it that I can
delete a key structure by undef'ing a hash?  I've just
double checked through the comments in the
TieRegistry.pm file and it looks as though specifying
KEY_READ should prevent me from deleting things.
If I am misunderstanding this can someone let me know
and also modify the above code snippet to demonstrate
how this should be achieved?

I'm using an older perl (Ativeperl 5.6.1 ) and related
modules on this system so I'd appreciate if someone
could try this small code snippet on their system with
a newer setup.

Thanks in advance,
PJ



                
____________________________________________________ 
On Yahoo!7 
24: Watch it from 9.30pm on Thursdays on Seven 
http://www.seven.com.au/seven/24
_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to