Use a Tk::Spinbox, see https://metacpan.org/source/SREZIC/Tk-804.033/examples/spinbox
See Re: can'yt figure out whats wrong in this code?, Re: Perl/Tk,How to limit the number of characters in Entry? and widget - Demonstration of Perl/Tk widgets, Entries and Spin-boxes: 3. Validated entries and password fields.
#!/usr/bin/perl --
use strict;
use warnings;
use Tk;
my $mw = tkinit;
for my $ix ( 0 .. 9 ){
my $box = $mw->Spinbox(qw/
-from -10
-to 10
-increment .01
-format %05.2f
-width 10
/,
)->pack ;
$box->set( $ix );
}
$mw->WidgetDump;
MainLoop;