Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Conditional use of Win32::TieRegistry

by Perlbotics (Bishop)
on Nov 13, 2017 at 18:56 UTC ( #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
Node Status?
node history
Node Type: note [id://1203279]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2021-05-07 01:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (83 votes). Check out past polls.

    Notices?