#!/usr/local/bin/perl use Tk; use strict; use warnings; my $main = new Tk::MainWindow(); my $entry_test = $main->Entry()->pack(); my $btn_test = $main->Button( -text => ' Test ', -command => sub { my $text = $entry_test->get(); eval { utf8::downgrade($text); }; &msg($main, $@) if ($@); } )->pack(); sub msg { my ($parent, $msg) = @_; $parent->messageBox( -title => 'Event', -message => $msg, -type => 'ok', -icon => 'info' ); } MainLoop();