Syst has asked for the wisdom of the Perl Monks concerning the following question:

@jack2 = ('upd_ss_accum_base','upd_ss_accum_dar','upd_ts_accum_base',' +user_color','user_def','user_log'); foreach (@jack2) { print "Doing table " . $_; $copy_handler->copy([$_]); }
I am trying to copy some tables from one db to another db. I get alot of errors when I do it, I was trying to run them once at a time. When I run the above code, it does all the db copying, then prints out the -doing table - line. Is there anyway to get it to do one db copy then print and go back and forth. I am missing something here. right? It should work as it is coded, print then copy then print then copy.
Please tell me what I am missing

Replies are listed 'Best First'.
Re: for-loop question
by Errto (Vicar) on Jan 22, 2005 at 23:57 UTC
    I can't tell you what the errors mean since you haven't shown us what they are nor any of the code that causes them. But I have a pretty good guess about how you can get those printed lines to appear when you want them. First add the line
    $| = 1;
    at the beginning of your program, then change your print statement to something like
    print "Doing table $_\n";
    This will make sure that your print output is not buffered, which is probably the problem you're having now.
Re: for-loop question
by Zaxo (Archbishop) on Jan 22, 2005 at 23:41 UTC

    There is nothing wrong with what you show. The for loop is not the problem. You'll have to show what kind of object $copy_handler is, and what its copy method does. In code.

    Since they are related to some kind of db operations, you should look at what kind of error checking and reporting they do. The error messages are likely to tell you what's wrong. How about telling us what they say?

    After Compline,
    Zaxo