[Israel.pm] Win32::TieRegistry question

Scott Weisman sweisman at pobox.com
Mon Jul 9 05:48:49 PDT 2007


I've had the need to do some Perl development on Windows. One of the
things I need to do is get all the DSNs available. I figured doing
this using the Registry was easier than using the ODBC API. After much
trial and error, this is what I got to work:

use Win32::TieRegistry ();

use Data::Dumper;

my $registry;

use Win32::TieRegistry (Delimiter => '/', ArrayValues => 0, TiedRef =>
\$registry, 'KEY_READ');

my $entry = $$registry{'LMachine/SOFTWARE/ODBC/ODBC.INI/'};

my $odbc_list = $$entry{'ODBC Data Sources/'};

print Dumper($entry), "\n"; # see note below

print Dumper($odbc_list), "\n";

Note 1: If I include this line, $odbc_list dumps this (which is correct):

$VAR1 = bless( {

                 '/TEMPDB' => 'Pervasive ODBC Engine Interface',

                 '/afw_davis' => 'SQL Server',

                 '/afw_moser' => 'SQL Server',

                 '/DEMODATA' => 'Pervasive ODBC Engine Interface',

                 '/DefaultDB' => 'Pervasive ODBC Engine Interface',

                 '/AGYFORMS' => 'Pervasive ODBC Engine Interface'

               }, 'Win32::TieRegistry' );

However, if don't dump $entry first, all I get is this (which is incorrect):

$VAR1 = bless( {}, 'Win32::TieRegistry' );

Even if I just reference $entry, nothing happens. I have to dump it first.

Can someone please help me? This is driving me crazy!



More information about the Perl mailing list