sub do_while { use Fcntl qw(:seek); #count lines and rewind while(){$linetotal++} seek FILE0, 0, SEEK_SET or die "Cannot rewind file: $!"; while(){$linetotal++} seek FILE1, 0, SEEK_SET or die "Cannot rewind file: $!"; while(){$linetotal++} seek FILE2, 0, SEEK_SET or die "Cannot rewind file: $!"; print "$linetotal\n"; $progressbar = $main->ProgressBar( -length => 200, # Actually width -width => 20, # Actually height -gap => 0, -value => 0, -colors => [0, 'pink'], )->pack(-pady => 5, -padx => 5); while () { my $line = $_; chomp($line); do_opt0($line); if ( $line ne $token ) { print SFILE "$token"; } $progressbar->value($progressbar->value + (100/$linetotal) ); $main->update; } while () { my $line = $_; chomp($line); do_opt1($line); if ( $line ne $token ) { print SFILE "$token"; } $progressbar->value($progressbar->value + (100/$linetotal) ); $main->update; } while () { my $line = $_; chomp($line); do_opt2($line); if ( $line ne $token ) { print SFILE "$token"; } $progressbar->value($progressbar->value + (100/$linetotal) ); $main->update; } }