#!/usr/bin/perl use 5.010; use strict; use warnings; use autodie; use Tk; require Tk::ProgressBar; my $mw = tkinit; my $progress_bar = $mw->ProgressBar( -variable => \my $p, -length => 500, # width -width => 30, # height -blocks => 50, -resolution => 2, -from => 0, -to => 100, -colors => [ 0, 'green', ], )->pack( -fill => 'x', ); my $update_text = "-"; my $label = $mw->Label( -textvariable => \$update_text, )->pack; $mw->fileevent(\*STDIN, readable => \&update); MainLoop; sub update { my $line = ; if (! defined $line) { $mw->fileevent(\*STDIN, readable => ''); return; } if ($line =~ m!(\d+)/(\d+)!) { $update_text = "$1 / $2"; $p = $2 ? $1 / $2 : 1; $p *= 100; } }