GOAL:
Using Win32::TieRegistry, I am opening a registry key in Windows NT4, deleting a subkey, and then closing the registry key using undef. Then I am opening a second key, deleting a subkey, and then closing the second registry key using undef. The second key should not be deleted until the first key is already deleted. My assumption was that closing the first key using undef would enable me to delete the second key, but it's not working in Perl as I had expected. Both keys are being deleted, but the result is similar to what would happen if I deleted the second key first and the first key second.

POSSIBLE SOLUTION:
I found Flush( $bFlush ) in the TieRegistry documenation:
"Flushes all cached information about the Registry key so that future uses will get fresh data from the Registry. If the optional $bFlush is specified and a true value, then RegFlushKey() will be called, which is almost never necessary."

QUESTIONS:
Maybe I need to use Flush after deleting the first key, but I can't figure out how it works. I have no idea what $bFlush is, what it means by "specified", what it means by "and a true value", or what RegFlushKey() is and why it would be necessary. Even if I don't need to "specify" $bFlush, I don't know the correct syntax for using Flush. It says that Flush( $bFlush ) is a member function defined for use on Win32::TieRegistry objects.

SOME FAILED ATTEMPTS:
Assuming that it's not a method, I was thinking along these lines:
$OpenKey = Flush( $bFlush );
or
Flush();
and I get this error:
Undefined subroutine &main::Flush called...

So I try this:
$OpenKey = Win32::TieRegistry->Flush( $bFlush );
and I get this error:
Can't use string ("Win32::TieRegistry") as a HASH ref while "strict refs" in use at C:\...TieRegistry.pm line 527

This doesn't give me an error, but it doesn't work:
$Registry->Flush();
Debugging, I've noticed that it doesn't step through the entire Flush subroutine.

So, I tried this:
$Registry->Flush( $bFlush );
and I get this error:
Usage: $Key->Flush( $bFlush );

So, I tried this and got the same usage error:
my $key = $Registry->{"LMachine"};
$key->Flush( $bFlush );

ADDITIONAL NOTE:
Someone else has asked a similar question as well. The original question was missing some details, and the follow up question about Flush didn't get a response.

In reply to TieRegistry - How does Flush( $bFlush ) work? by trout16

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.