foreach my $dir (@SOURCE) { next if ($dir eq any(@exclusion_list)); my $mw = MainWindow->new; # Don't use existing window. my $cmd = "cp -a $home_value\/$dir $storage"; while (system($cmd)) { my $progress = $mw->ProgressBar( -width => 200, -height => 20, -from => 0, -to => 100, -blocks => 10, -colors => [0, 'green', 50, 'yellow' , 80, 'red'], -variable => \$percent_done ); } }