sub new{ my $class = shift; my %cfg = ( user => '', pass => '', port => 3306, host => 'localhost', base => '', @_ ); # das Objekt mit dem DB-Handle und dem Statement-Handle my $self = bless{ DBH => undef, STH => undef, }, $class; # Prepared Statement my $q = q(SELECT name FROM unicode WHERE cpd = ?); my $dsn = "DBI:mysql:database=$cfg{base};host=$cfg{host};port=$cfg{port}"; eval{ $self->{DBH} = DBI->connect_cached( $dsn, $cfg{user}, $cfg{pass}, { RaiseError => 1, PrintError => 0, } ); $self->{STH} = $self->{DBH}->prepare_cached($q); }; return $@ ? undef : $self; }