package db; # db.pm use strict; use warnings; use Data::Dumper; use DBI; our $dbh = undef; sub connect { # The arguments to DBI->connect are ignored by Test::MockDBI $dbh = DBI->connect('DBI:mysql:test', 'foo', 'bar'); } sub disconnect { $dbh->disconnect(); } sub select_i_from_t { my $sth = $dbh->prepare(q{select i from t}) or die "prepare failed"; $sth->execute() or die "execute failed"; my $arref = []; while (my $row = $sth->fetchrow_arrayref()) { push @$arref, $row->[0]; } return $arref; } 1; __END__