use Tk; use Tk::JPEG; use File::Glob ':glob'; my @jpgs = bsd_glob('*.jpg'); my $index = 0; my $mw = MainWindow->new(title => "JPEG"); my $b = $mw->Button()->pack(); $mw->after(1000, \&next_image); MainLoop; sub next_image { #the eval was not there at the beginning, but then I had some broken image, and the application stoped... eval {$b->configure(-image => $mw->Photo('-format' => 'jpeg', -file => $jpgs[$index])); $mw->configure(-title => $jpgs[$index]) }; $mw->after(1000, \&next_image) if (++$index <= $#jpgs); }