I'd like to have delete operations on the registry return true/false. The docs for TieRegistry (at tinyurl.com/5ofltk) say
".. by calling the FastDelete member function: # # $prevSetting= $regKey->FastDelete(1); # # which will cause all subsequent delete operations via $regKey to sim +ply return a true value if they succeed.
Unfortunately I'm too dumb to get it to work. In my code, when deleting a reg value (not key) the delete operation either deletes the value and returns its data, or, when the value is not in the registry the delete fails and returns a string "The system cannot find the file specified."

Can some kind monk please point out the error of my ways?
Here's a simple sample:

use Win32::TieRegistry( Delimiter=>"/", ArrayValues=>1 ); $key = "LMachine/Software/Microsoft/Windows/CurrentVersion/SharedDlls/ +"; $value = "c:\\aaa.aaa"; # $Registry->{ $key } = { "/$value" => [ "0x0003", "REG_DWORD" ] }; $prevSetting = $Registry->FastDelete(1); $res = delete $Registry->{ $key . $value }; if( $res ) { print( "removed value $value and res is $res\n" ); } else { print( " delete failed and res is '$res'\n" ); }
Those docs go on to say "This optimization is automatically done if you use delete in a void context."
It may be asking too much, but if someone can tell me in how to use delete in a void context, that would also be helpful.
Many thanks

In reply to TieRegistry FastDelete problem by anadem

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.