Errata:  The "last" print statement in the 'while' loop is the focus......

Tony Esposito
Oracle Developer, Enterprise Business Intelligence
XO Communications
Plano, TX  75074
Work Phone: 972-516-5344
Work Cell: 972-670-6144
Email: [EMAIL PROTECTED]


-----Original Message-----
From: Esposito, Anthony 
Sent: Tuesday, January 06, 2004 2:54 PM
To: [EMAIL PROTECTED]
Subject: 'print' output on one line

I have a perl program ( with DBI ) which prints out a line to STDOUT
after every 100 database commits.  I would like the 'print' to just
refresh the current line every time but - not knowing how to get around
it - the program instead prints a new line every 100 commits like so:

 

INFO 3: start deleting rows.

Rows deleted: 100

Rows deleted: 200

Rows deleted: 300

Rows deleted: 400

.

.

.

INFO 4: delete_rows.pl program ended.

 

I would like the output to just stay on one line and just update the
count as the program proceeds.  So the output - when done - would just
be 

 

INFO 3: start deleting rows.

Rows deleted: 400

INFO 4: delete_rows.pl program ended.

 

Is there a 'print' option/escape character the sends the file pointer (
for STDOUT in this case ) back to the beginning of the line?

 

Here is the current code segment - the focus here is on the last 'print'
statement:

 

print "INFO 3: start deleting rows.\n";

while(($row_data) = $sth1->fetchrow) {

  if(! defined ($sth2->execute($row_data))) {   # execute DELETE

    print "ERROR 4: execute of DELETE statement failed.\n";

    exit(int 4);

  }

  $row_counter = $row_counter + 1;

  if($row_counter >= 100) {

    $dbh->commit;

    $rows_deleted = $rows_deleted + $row_counter;

    print "Rows deleted: $rows_deleted\n";

    $row_counter = 0;

    }

}

print "INFO 4: $0 program ended.\n";

 

      Thanks for any help you can offer....

 

Tony Esposito

Oracle Developer, Enterprise Business Intelligence

XO Communications

Plano, TX  75074

Work Phone: 972-516-5344

Work Cell: 972-670-6144

Email: [EMAIL PROTECTED] 

 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to