Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Conditional use of Win32::TieRegistry

by Perlbotics (Archbishop)
on Nov 13, 2017 at 18:56 UTC ( [id://1203279]=note: print w/replies, xml ) Need Help??


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).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1203279]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2024-03-28 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found