Hello, In the below code I am desperately trying to accomplish the valid use of variable variable names but still fail. I have already read many sites, tutorials, mailing list posts, all saying that this is best accomplished by using a hash. Please would you tell me if I understood that correctly and, even more important, if I interpreted and tried to realize it correctly? And if someone could tell me why the script gives me errors and what to change to make it work, that would be great :-)
CODE: #!/usr/bin/perl use strict; use warnings; use DBI; use DBD::Oracle; my $DBI; my $dbh = DBI->connect("dbi:Oracle:$db", $dbusr, $dbpw, {RaiseError=>1, AutoCommit=>1}) or die "Verbindung zur DB fehlgeschlagen: $DBI:: errstr\n"; # Hash for variable variable names # Hash für die verschiedenen Umgebungsgruppen my %umg = ( 'Auslieferungs' => 'ausl', 'Entwicklungs' => 'entw', 'EQS' => 'eqs', 'IQS' => 'iqs', 'MVB-Akademie' => 'aka', 'Sonstige' => 'rest', ); while ( ( my $lang, my $kurz ) = each %umg ) { my $sql_$kurz = "select * from umgebungen_vw where beschreibung like \'$lang%\'"; my $sth_$kurz = $dbh->prepare($sql_$kurz); my $lines_$kurz = $dbh->selectall_arrayref($sql_$kurz); my @lines_$kurz = @{$lines_$kurz}; print "<table border=\"1\">\n"; print "<h1>Versionsübersicht $lang-Umgebungen</h1>"; print "<thead>"; print "<tr> <th>$sth_$kurz->{NAME}->[0]</th> <th>$sth_$kurz->{NAME}->[1]</th> <th>$sth_$kurz->{NAME}->[2]</th> <th>$sth_$kurz->{NAME}->[3]</th> <th>$sth_$kurz->{NAME}->[4]</th> <th>$sth_$kurz->{NAME}->[5]</th> <th>$sth_$kurz->{NAME}->[6]</th> <th>$sth_$kurz->{NAME}->[7]</th> <th>$sth_$kurz->{NAME}->[8]</th> <th>$sth_$kurz->{NAME}->[9]</th> <th>$sth_$kurz->{NAME}->[10]</th> <th>$sth_$kurz->{NAME}->[11]</th> </tr>\n"; print "</thead>"; print "<tbody>"; my $rnd_color = color(); # separate function, not c&p-ed foreach ( @$_ ) { print "<tr bgcolor=\"$rnd_color\"> <td>$$_[0]</td> <td>$$_[1]</td> <td>$$_[2]</td> <td>$$_[3]</td> <td>$$_[4]</td> <td>$$_[5]</td> <td>$$_[6]</td> <td>$$_[7]</td> <td>$$_[8]</td> <td>$$_[9]</td> <td>$$_[10]</td> <td>$$_[11]</td> </tr></b>\n"; } print "</tbody>"; print "</table>\n"; print "</body>\n"; print "</html>\n"; $sth_$kurz->finish(); } $dbh->disconnect(); 1; ERRORS: Scalar found where operator expected at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 57, near "$sql_$kurz" (Missing operator before $kurz?) Scalar found where operator expected at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 58, near "$sth_$kurz" (Missing operator before $kurz?) Scalar found where operator expected at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 58, near "$sql_$kurz" (Missing operator before $kurz?) Scalar found where operator expected at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 59, near "$lines_$kurz" (Missing operator before $kurz?) Scalar found where operator expected at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 59, near "$sql_$kurz" (Missing operator before $kurz?) Scalar found where operator expected at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 60, near "@lines_$kurz" (Missing operator before $kurz?) Scalar found where operator expected at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 60, near "$lines_$kurz" (Missing operator before $kurz?) Scalar found where operator expected at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 107, near "$sth_$kurz" (Missing operator before $kurz?) syntax error at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 57, near "$sql_$kurz " syntax error at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 58, near "$sth_$kurz " syntax error at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 59, near "$lines_$kurz " syntax error at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 60, near "@lines_$kurz " syntax error at /opt/freeware/apache/share/cgi-bin/umgebungen.pl line 107, near "$sth_$kurz" Execution of /opt/freeware/apache/share/cgi-bin/umgebungen.pl aborted due to compilation errors. Thanks in advance! Kind regards, Nora