open APPLIST, $applistfile or die "Can't open $applistfile file: $!"; while () { push @inpfile, [split /\n/]; } close APPLIST or die "Cannot close $applistfile: $!"; #### foreach my $ifile (@inpfile) { print STDOUT "\nFile $ifile being applied\n"; # First read the contents of the file into an array { local $/; open SLURP, $ifile or die "can't open $ifile: $!"; @filedata = ; close SLURP or die "cannot close $ifile: $!"; } # split the data into each statement (i.e. between go's) my @filedata_new = (); foreach(@filedata) { push @filedata_new, split('go', $_); # split on the go } # now pass each statement to the opened connection and execute it foreach my $statement (@filedata_new) { chomp($statement); $statement=~s/^\s+//; #print STDOUT "The statement being executed is $statement\n"; my $sth = $dbh->prepare("$statement"); $sth->execute; } }