#!/usr/bin/perl use strict; use warnings; use Tk; use Regexp::Common qw/number/; my $top = MainWindow->new(); $top->geometry('300x200'); $top->fontCreate('big', -family=>'courier', -weight=>'bold', -size=>int(-18*18/14)); my %entries; my $current = 1; for(1..4){ $entries{$_}{'value'} ||= ''; $entries{$_}{'entry'} = $top->Entry( -font => 'big', -textvariable => \$entries{$_}{'value'}, -width => 2, -validate => 'key', -vcmd => \&validate, )->pack(-side =>'left',-padx => 5); } $entries{$current}{'entry'}->focus; MainLoop; sub validate{ my $val = shift; if( $val =~ /^$RE{num}{real}{-base=>'16'}$/ ) { if( length $val == 2){ print "2\n"; $current++; if($current > 4){$current = 4} $entries{$current}{'entry'}->focusForce; $top->update; } return 1; } return 0; }