# Your script should have $MainWindow->after(10,\&update_var); # this is the update variable callback. sub update_var { $status_var = $work_done/$total; $status_var = $status_var * 100; # get percentage }