use Tk; use Tk::JPEG; use File::Glob ':glob'; my @jpgs = bsd_glob('*.jpg'); my $index = 0; my $mw = MainWindow->new(title => "JPEG"); my $image = $mw->Photo(-format => 'jpeg', -file => $jpgs[$index]); my $b = $mw->Button( -image => $image )->pack(); $mw->after(1000, \&next_image); MainLoop; sub next_image { $image->read( $jpgs[$index], -shrink ); $b->configure(-image => $image); $mw->configure( -title => sprintf "$jpgs[$index] [%dx%d]", $image->width, $image->height ); $mw->after(1000, \&next_image) if (++$index <= $#jpgs); }