#! /usr/bin/perl use warnings; use strict; use Tk; my $entryText = 1; print "Perl-Version: $]\nTk-Version: $Tk::VERSION\n"; my $mw = MainWindow->new(); my $entry = $mw->Entry( -textvariable => \$entryText, -validate => 'all', -validatecommand => \&ValidateCmd, ) ->pack( -side => 'left' ); $mw->Button( -text => 'increase', -command => sub { $entryText++ }, ) ->pack( -side => 'right' ); MainLoop; sub ValidateCmd { my( $newValue ) = @_; { local $" = '] ['; no warnings 'uninitialized'; print "ARGS: [@_]\n"; } # return error if value > 3 and don't change the content if( $newValue > 3 ) { print "Error: Too big: $newValue\n"; return 0; } # if return 1; } # ValidateCmd