Accessing Pervasive.SQL With Perl

Page Last Modified: 01/02/10

Home Links ODBC (DBI) Contact

Win32::ODBC - Examples - checking for available datasources

To check what ODBC data source names (DSNs) have been created, we use the DataSources method. We then use regular expressions to filter out non-Pervasive DSNs:

use strict;
use warnings;

use Win32::ODBC;

my(%dsn, $key) = Win32::ODBC::DataSources();

foreach $key (sort keys %dsn)
print "$key\t-\t$dsn{$key}\n" if $dsn{$key} =~/Pervasive/;

DataSources creates a warning ("Use of uninitialized value in subroutine entry at") on my ActiveState Perl 5.8 development machine due to no parameters being passed - nevertheless tries to use whatever is passed through.

Compare this code to the DBI example, which of course has ODBC as just one of several drivers.

Home Links ODBC (DBI) Contact

All content on this site is copyright
Neil Hughes 2010 - 2017