use IO::Handle; # for older perls use Time::HiRes qw(usleep); my $pid = open my $fh, "|-", q{zenity --title=Working --width=400 --progress --percentage=50 --no-cancel --auto-kill --auto-close} or die "Could not open zenity: $!"; $fh->autoflush(1); for my $i (1 .. 100) { usleep 100_000; # microseconds print $fh "$i\n"; # move the bar print $fh "#Now on $i...\n"; # update the text print "We've done $i\n"; if ($i >= 50) { #kill 2 $pid; # not as portable print $fh "100\n"; # more portable with --auto-kill last; } }