package Foo; use DBI; use Carp; use strict; sub new { my $class = shift; my $self = {}; bless $self, $class; # THE PROBLEM: $self->{'dbh'} = DBI->connect(@_) or carp; return $self; } 1; #### # THE SAME PROBLEM: eval { $self->{'dbh'} = DBI->connect(@_,{RaiseError=>1,PrintError=>0}) }; carp $@ if $@; #### use strict; use Foo; use DBI; print "Comparing wrapper:\n"; my $foo = Foo->new(qw(DBI:mysql:mysql:host user pass)); print "\nComparing DBI:\n"; my $dbh = DBI->connect(qw(DBI:mysql:mysql:host user pass));