my $nmbr = $mw->Entry(-width => 10, -text => 10); #### #!/usr/bin/perl -w use Tk; use strict; my $mw = MainWindow->new; my $value = 10; $mw->Label(-text => 'Number')->pack; my $nmbr = $mw->Entry(-width => 10, -textvariable => \$value); $nmbr->pack; $mw->Button( -text => 'Print', -command => sub{do_print($value);} )->pack; MainLoop; sub do_print { (my $value) = @_; print "Printing number $value\n"; } #### $mw->Button( -text => 'Randomise', -command => sub{do_randomise(\$value);} )->pack; #### sub do_randomise { (my $value) = @_; $$value = int rand 100; }