ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-admin
perl-win32-admin
TieRegistry and KEY_READ - not being honoured?
by Paul Jansen other posts by this author
Jul 18 2006 7:34AM messages near this date
view in the new Beta List Site
TieRegistry and 64 bit registry (x64) | Re: TieRegistry and KEY_READ - not being honoured?
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@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Paul Jansen
Paul Jansen

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved