in reply to autoclose a Perl-Tk window after 2 seconds.

As said in the CB,
use Tk; my $mw = MainWindow->new; $mw->Label(-text => "Foo")->pack; $mw->after(2000, sub {exit}); MainLoop;

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: autoclose a Perl-Tk window after 2 seconds.
by jdporter (Paladin) on Apr 09, 2007 at 14:10 UTC

    shmem's answer is exactly correct.

    However, because I've encountered this at various times, I'd like to share another point that sooner or later might be useful to whomever.

    When you simply want the MainLoop to finish, and continue executing code after it, you don't want to exit, but instead kill the MainWindow:

    $mw->after(2000, sub { $mw->destroy }); MainLoop; warn "MainLoop ended; continuing...\n";
    A word spoken in Mind will reach its own level, in the objective world, by its own weight
      Thanks everyone for their collective wisdom in solving my problem.