http://www.perlmonks.org?node_id=1203279


in reply to Conditional use of Win32::TieRegistry

Uncomment this line:

my ($Registry, $IEKey);
and it will work. $Registry was not defined while using strictures.

Output (linux):

No module None of that stuff here

Update:

Not tested on Windows, though (not available here). If that still fails, you have another problem. Perhaps, you need to call the import() class method:

eval { require Win32::TieRegistry; Win32::TieRegistry->import(); };

Update2: My try on a cleanup, after getting hands on a Windows system:

use strict; use warnings; our $Registry; BEGIN { $Win32::TieRegistry::__LOADED = eval { require Win32::TieRegistry; Win32::TieRegistry->import( Delimiter => '/' ); 1; }; } sub use_mod { $Win32::TieRegistry::__LOADED; } print "On $^O\t-> "; if ( use_mod ) { my $IEKey = $Registry->{'HKEY_CURRENT_USER/Software/Microsoft/Inter +net Explorer/Main/'}; print 'Show status bar: ', $IEKey->{'/Show_StatusBar'}, "\n"; } else { print "None of that stuff here.\n"; } __DATA__ On MSWin32 -> Show status bar: yes On linux -> None of that stuff here.

Replies are listed 'Best First'.
Re^2: Conditional use of Win32::TieRegistry
by hilitai (Monk) on Nov 13, 2017 at 19:02 UTC
    Yes, it works on Linux. But now it fails on Windows (the $IEKey variable should contain a value like Win32::TieRegistry=HASH(0x1dd000), but it is null).