in reply to DBI query where table name is a variable
At that point, the table name gets expanded into the SQL string, and it will not change, even if you re-assign to $table.