#!/usr/local/bin/perl use strict; use warnings; use Tk; my $mw = tkinit(); my $txt_var; my $spin = $mw->Spinbox( -from => 0, -to => 100, -textvariable => \$txt_var, -command => sub {print $txt_var . "\n"} ) ->pack(-side => 'left'); my $cmd = $spin->cget('-command'); $spin->bind('', $cmd); MainLoop;