use strict; use DBI; use DBD::mysql; require Exporter; my @ISA = ('Exporter'); my @EXPORT_OK = qw(new user_get_users); sub new {    my $dsn = 'DBI:mysql:moorland:localhost';  # datasourcename:  wenn myserver weggelassen wird,                             # wird standardmäßig localhost verwendet.    my $attributes = { PrintError => 0, RaiseError => 0, "AutoCommit" => 1, }; # siehe Doku zu DBI    $pgdb = DBI->connect($dsn, $user, $password, $attributes)    or main::writeDbhError("Error in connecting to $dsn", die => 1);  # immer Returncodes und Fehler auswerten!!! } #new sub get_res { # Returns an sorted twodimentional Array: [ Foreach Ressourceid: [ ressourceid, ressourcename, quantity ] ]  my $self = shift;  my $userid = shift;  if (my $dataref = dbselect("SELECT restype, quantity FROM res_distribution WHERE userid=$userid")) {    foreach my $ressource (@$dataref) {      $ressource->{'RESNAME'} =        dbselect("SELECT name AS resname FROM res_types WHERE id=" . $ressource->{'RESTYPE'})->[0]->{'RESNAME'}            #or die("Fehler, Dem".$db->lasterror);            or die("Fehler: $pgdb->errstr\n");    }    return $dataref;  } else {    return;  } }