The main problem here is that just because the command option can accept [$main => 'destroy'] as a configuration for an internal Callback does not mean that the same syntax can be used standalone outside of that context. What you're looking for is: $main->destroy like the following stripped down example.

use Tk; my $main = MainWindow->new; $main->Button( -text => 'Submit', -command => [\&Submit] )->pack; MainLoop; print "Script continues after mainloop terminated\n"; sub Submit { print "Submit called\n"; $main->destroy; }

Destroying the MainWindow allows the Event Loop created by MainLoop to terminate, allowing the lines following MainLoop to execute.

Rob

In reply to Re: How do you exit PERL TK menu without exiting the script too ? by rcseege
in thread How do you exit PERL TK menu without exiting the script too ? by ljsmith91

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.