http://www.perlmonks.org?node_id=1029906

dabella12 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks I need a little help :) I'm writing a script that needs to update a label with the current time. here is the code I'm using but it doesn't work

#!/usr/bin/perl use strict; use warnings; use diagnostics; use Tk; use Date::Manip; my $time=&UnixDate('now',"The time is: %r on %B %d, %Y"); my $mw=MainWindow->new(-title=>'Time Test'); my @top = qw/-side top -fill both -padx 2 -pady 2 -expand 1/; my @left = qw/-side left -fill both -padx 2 -pady 2 -expand 1/; my $frm=$mw->Frame(-bd =>2); my $frm1=$mw->Frame(-bd =>2); my $oper=$frm->Button( -text => "Entrada De Operaciones", -command => sub{print "Hello World\n"}, ); my $client =$frm->Button( -text => 'Informe De Clientes', -command => sub{print "Hello World\n"}, ); my $general =$frm->Button( -text => 'Informe General', -command => sub{print "Hello World\n"}, ); my $util =$frm->Button( -text => 'Utilidades', -command => sub{print "Hello World\n"}, ); my $exit =$frm->Button( -text => 'Exit Application', -command => sub{exit}, ); my $lb=$mw->Label(-text=>\&update_time)->pack(@top); $frm->pack(@top); $oper->pack(@top); $client->pack(@top); $general->pack(@top); $util->pack(@top); $exit->pack(@top); MainLoop; sub update_time { $time=&UnixDate('now',"The time is: %r on %B %d, %Y"); print "$time\n"; $lb->configure(-text=>"$time"); $mw->update; $mw->after(1); }

This doesn't work for some reason.