#!/usr/bin/perl use Tk; my($text1, $text2); my $max_len = 8; my $mw = tkinit; my $entry1 = $mw->Entry(-textvariable => \$text1)->pack(); my $entry2 = $mw->Entry(-textvariable => \$text2)->pack(); $entry1->bind('' => sub { $text1 = substr($text1, 0, $max_len);                               $entry2->focus() if length($text1) == $max_len;                               }); $entry2->bind('' => sub { $text2 = substr($text2, 0, $max_len); }); MainLoop();