#!/usr/bin/perl -w use strict; use warnings; use DBI; my ($dbh, $sth); my %software; my @installed; my $iid = '1'; # Inventar-ID # main $dbh = &connect(); &fetch_software(); &fetch_installed($iid); &html_selection(); $dbh->disconnect(); exit(0); # subs sub is_in { # is_in gibt die Anzahl an Übereinstimmungen eines Elementes # zu einer Menge in einem Array zurück. my $test = shift @_; my @in = @_; my $answer = 0; for (@in) { $answer++ if ($test eq $_); } return $answer; } sub connect { return DBI->connect ("DBI:mysql:host=192.168.0.1;database=meine", "ich", "geheim", {PrintError => 0, RaiseError => 1}); } sub fetch_installed { my $iid = shift @_; $sth = $dbh->prepare (" SELECT SOID FROM nutzt_software WHERE IID = $iid "); $sth->execute(); while (my ($soid) = $sth->fetchrow_array()) { push @installed, $soid; } $sth->finish(); } sub fetch_software { $sth = $dbh->prepare (" SELECT SOID, Produkt FROM Software "); $sth->execute(); while (my ($soid, $produkt) = $sth->fetchrow_array()) { $software{$soid}=$produkt; } $sth->finish(); } sub html_selection { print "\n"; }