#!/usr/bin/perl use strict; use warnings; use Gtk2 '-init'; my $win = Gtk2::Window->new; $win->set_border_width (6); $win->set_title ('Simple App'); $win->signal_connect (destroy => sub { Gtk2->main_quit; }); my $label = Gtk2::Label->new ('First Message'); $win->add ($label); # the following will happen ever 1/2 a second Glib::Timeout->add (500, sub { $label->set_text ('A random number: '.rand); # need to return 1 so that the timeout stays installed and gets # called again 1; }); $win->show_all; Gtk2->main;