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

I keep getting an error (an uncaught exception) on the second key and don't know why. Here's my code:

use Win32::TieRegistry( Delimiter=>"/" ); my opt1 = $Registry->{"CUser/Control Panel/Desktop/TileWallpaper"} || +die $^E; my opt2 = $Registry->{"CUser/Control Panel/Desktop/WallpaperStyle"} || + die $^E;

The full error is "The system could not find the environment option that was entered". I am baffled at this error because the key does exist. I looked at it with regedit. Furthermore, I am logged in as Administrator and running the script as such. I can't see how this could possibly be a permissions problem. What's weirder is that the script is finding the first key with no problem. What am I missing?

Replies are listed 'Best First'.
Re: TieRegistry problem
by djantzen (Priest) on Jun 17, 2003 at 04:20 UTC

    The key exists, but is it defined? Your assignments are effectively testing to see if the key lookup returns a true value, and if not then die is executed. If you don't mind having a key with a false value, then use exists, otherwise make sure there's a true value specified there.

    See also What is True and False in Perl?


    "The dead do not recognize context" -- Kai, Lexx
      5 hours. That's how long I've been sitting in this sweaty chair in front of my computer as I poured through the TieRegistry docs. I would give you 50 XP if I could. :)