my $last = pop @tables; foreach my $table (@tables) { process($dbh,$table); print ",\n"; } process($dbh,$last);