#!/usr/bin/env perl use strict; use warnings; $| = 1; use DBI; $SIG{__WARN__} = \&handle_warnings; my $dbh = DBI->connect('dbi:AnyData:'); $dbh->{HandleError} = \&handle_errors; $dbh->{RaiseError} = 0; $dbh->{PrintError} = 0; $dbh->{PrintWarn} = 0; $dbh->{ShowErrorStatement} = 0; $dbh->{Warn} = 0; $dbh->func( 'cars', 'CSV', 'cars.csv', 'ad_catalog'); my $sth = $dbh->prepare('select make, model from cars'); $sth->execute(); while (my $row = $sth->fetch) { print "@$row\n"; } $sth->finish; $dbh->disconnect; sub handle_warnings { print Data::Dumper->Dump([\@_], ['*_']); my $warning = shift; print "Handling WARNING:\n$warning\n"; return if $warning =~ /handle .*? cleared whilst still active/ms; } sub handle_errors { print Data::Dumper->Dump([\@_], ['*_']); my $error = shift; print "Handling ERROR:$error\n"; 1; }