View Single Post
  #1 (permalink)  
Old 01-03-04, 01:23 PM
Greenhorn Greenhorn is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Show Progress Meter

I posted earlier re comparing files. Wrote a program which is complete except for one thing- I want to display a progress meter which is working, but not working correctly.

Here's the code...
Code:
#COMPARE COMMON FILES
undef $file;
print "\n\n\n\n\nCOMPARE - PROGRESS METER (each file scanned: \"x\" )\n\n\n";
foreach $file(@common) {
    $cse_file=$startdir.$file;
    $ftb_file=$startdir2.$file;
    print "x";
    if (compare($cse_file,$ftb_file) ne 0) {
        $old_ftb_file=$ftb_file;
        $different=1;
        $diff_mark=1;
        if ($ftbtag) {
            substr($ftb_file, -4, 0) = '.FTB';
            rename($old_ftb_file,$ftb_file);
            substr($file, -4, 0) = '.FTB';
            push(@renamed_ftb_files,$file);
        }
    }
    if ($diff_mark) {
        print "\n\nDIFFERENCE FOUND BETWEEN:\n";
        print "$cse_file"."\nand\n"."$old_ftb_file\n\n";
        undef $diff_mark;
    }
}
if (!$different) { print "\n\nNO DIFFERENCES FOUND IN ANY OF THE COMMON FILES!\n"; }
Now, each "x" shows up for each file scanned, but ONLY when the files are displayed as being different - not per file (the whole line of accumulated x's are only displayed when the "DIFFERENCE FOUND" line is displayed.)

i.e.
Quote:
xx

DIFFERENCE FOUND BETWEEEN:
c:\123.txt
and
d:\123.txt

xxxxxxxxxxxxxxxxxx

DIFFERENCE FOUND BETWEEN:
c:\somedir\456.doc
and
d:\somedir\456.doc

xxxxxxxxxxx

DIFFERENCE FOUND BETWEEN:
c:\789.java
and
d:\789.java
How can I get each "x" to show up one after another like a progress meter on EVERY RUN THRU THE FOREACH LOOP so I can be sure that the script isn't hung as opposed to just scanning large or multiple files?

Minor issue as it doesn't exactly affect performance, but the few brain cells I have left are failing me and I want to be sure the script is working when my boss turns the corner.

Much appreciated!
(Chas- care to take a stab at this?)

Adam

Last edited by Greenhorn; 01-03-04 at 01:27 PM.
Reply With Quote