use Gtk3; my $window = Gtk3::Window->new ('toplevel'); my $button = Gtk3::Button->new ('Quit'); $button->signal_connect (clicked => sub { Gtk3::main_quit }); $window->add ($button); $window->show_all; my $id = Gtk3->timeout_add(1000, \&handler, $data); Gtk3::main; sub handler { my ($data) = @_; print "timed out ... \n"; # return 1 if you want the handler to be called again later # return 0 to stop the handler from being called again return 1; } result: perl test0.pl Segmentation fault (core dumped)