use Tk; use Tk::DialogBox; use strict; use warnings; my $top = new MainWindow(-title => "demo"); my $save = $top->Button(-text => "Goto line", command => \&process_save)->pack(); my $line_num; MainLoop; sub process_save { my $dialog = $top->DialogBox(-title => "Save?", -buttons => ["OK", "Cancel"]); $dialog->add("Entry", -text => \$line_num)->pack(); my $response = $dialog->Show(); print "[$response, $line_num]\n" #in real code, handle the response... }