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

I was using TieRegistry.pm and I kept getting an error from within the subroutine SubKeyNames. It related to returning a null hash (iirc). the hash was to have been generated and returned by _enumSubKeys. In single stepping through that code, I found that it was returning prematurely from the routine due to:
if( ! _NoMoreItems() ) { return (); }
Looking at that code, it appeared there was an assumption that an error would be generated by the call to RegEnumKeyEx (specifically, that it would be ERROR_NO_MORE_ITEMS) when there were no more subkeys. In single stepping this code, I saw that there was no error...the call to Errnum was returning zero. Modifying the code to NoMoreItems to check for either $_NoMoreItems or zero
sub _NoMoreItems { my $rval; return $_NoMoreItems =~ /^\d/ ? (_ErrNum() == $_NoMoreItems || _ErrNum() == 0) : _ErrMsg() =~ /$_NoMoreItems/io; }
eliminated the error and allowed the code to return data as expected. if this is expected, the change would have to be augmented to deal with a "no error" message as well. Has anyone know if there was an interface change for RegEnumKeyEx that resulted in it returning no error after processing the last subkey? gratz.

Replies are listed 'Best First'.
Re: Problem with TieRegistry.pm on windows xp/cygwin ($^E)
by tye (Sage) on Dec 13, 2007 at 18:27 UTC

    The problem appears more likely to be that $^E [a.k.a. Win32::GetLastError()] is being reset more quickly in your environment than in most. A better fix is to have Win32::TieRegistry::_ErrNum() stop using Win32::GetLastError() and start using Win32API::Registry::_regLastError() [and either just require a modern Win32API::Registry or make that change conditional on that function being available].

    Please report the bug over at rt://Win32::TieRegistry for the world to see. Would you mind also trying the change I suggested above in your environment (with your fix removed, of course) so I'll have verification that my guess is correct?

    I really need to release some module updates. I wish I didn't need a "day job". :)

    Update: Oh, and nice work on tracking down details about the bug.

    - tye        

      thanks for the input tye. I'll give that a shot sometime in the next couple of days and report back here...