use Tk; use Tk::Dialog; use strict; use warnings; my $top = new MainWindow(-title => "demo"); my $save = $top->Button(-text => "Close", command => \&process_save)->pack(); MainLoop; sub process_save { my $dialog = $top->Dialog(-title => "Save?", -text => "Content changed, save the changes?", -buttons => ["OK", "Cancel"]);#in real world, you only display this, if the content changed my $response = $dialog->Show(); print $response, "\n" #in real code, handle the response... }