1 2 3 4 5 6 7 8 9 10 11 12
my %name_option = ( "Kurz Bezeichnung der Tabelle" => { "tbl_name" => "xz2d4", # Name der Tabelle in der DB "tbl_cols" => [ "ID", "Datum", "Vorname", ... ] } ... )
1 2 3
my $select_handle = $dbh->prepare("SELECT " . join(", " , @{$name_option{$name}{"tbl_cols"}}) . " FROM [$mdb_tbl];");
1 2 3 4 5 6 7 8 9 10 11 12
my %name_option = ( "Kurz Bezeichnung der Tabelle" => { "tbl_name" => "xz2d4", # Name der Tabelle in der DB "tbl_cols" => [ {"name" => "ID", "breite" => 10}, {"name" => "Datum", "breite" => 8}, {"name" => "Vorname", "breite" => 20}, ... ] } ... )
1 2 3
my $select_handle = $dbh->prepare("SELECT " . join(", " , map { $_->{'name'} } @{$name_option{$name}{"tbl_cols"}}) . " FROM [$mdb_tbl];");
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#!/usr/bin/perl use warnings; use strict; package Name_option; sub new { my $classname = shift; my $args = {@_}; my $self = { name => $args->{name} || "default", cols => $args->{cols} || [] }; return bless($self, $classname); } sub getCols { my $self = shift; return @{$self->{cols}}; } package main; my $n = Name_option->new(name => "xz2d4", cols => ["ID", "Datum", "Vorname"]); my @cols = $n->getCols(); for my $i (@cols) { print "$i\n"; }