################################# script ################################# use strict; use Table; my $table = Table->old(); my @arrayoftablenames= qw(Table1 Table2 Table3 Table4 Table5 Table6); my $e = 0; foreach (@arrayoftablenames){ $e++; my $x = qw(tito$e); $table->create(form => $stmt, name => $x); } ####################################### module ####################################### package Table; use DBI; my $dbh = DBI -> connect("dbi:SQLite:dbname=Phylll.db", "", "",{RaiseError=>1, AutoCommit=>1}); sub old { ############################################### my ($class)= @_; my $hash = {}; bless ($hash,$class); } sub create{ ############################################### my ($self, %arg)=@_; my $form = $self->{form}=$arg{form}; my $tabler = $self->{name}=$arg{name}; $self->drop(argument => $tabler); my $stm = "create table $tabler ($form)"; my $st = $dbh->prepare($stm); $st ->execute(); } sub drop { ################################################# my ($self,%arg) = @_; my $arg = $self->{argument}=$arg{argument}; my $statement = "drop table if exists $arg"; my $st = $dbh->prepare($statement); $st ->execute(); } 1;