I am getting an error using the -command option with a Tk menubutton. Can anyone help? The subroutines I am calling are in a separate file this is "require". Here's the code:

#!D:\ActivePerl\bin\perl.exe -w require 'd:\\perlscripts\\A34980A.pm'; use English; use Tk; my $arg = ""; my $cmd = ""; my $main_menu = ""; my $menu_btn = ""; my $mtxsp = ""; my $mw = ""; my %cmd_list = ("A34980 Switch Cycles","\&get_SwCycles", "A34980 Info","\&getA34980Info"); # Setup GUI interface $mw = MainWindow->new; $mw -> minsize(qw(600 600)); $mw -> title(" Test TK"); # Create Frame to manage buttons $main_menu = $mw->Frame(-relief => "groove", -borderwidth => 3, -background => "light blue") -> pack(-side => + 'top', -fill = +> 'x'); # Create FILE menu button on top level $menu_btn = $main_menu -> Menubutton(-text => "Apps", -background => "light blue", -activebackground => "cyan", -foreground => "black") -> pack(-side = +> "left"); # Create List of sub menus from Apps menu button foreach $arg (keys %cmd_list) { $cmd = $cmd_list{$arg}; $menu_btn->command(-label => $arg, -background => "white", -activebackground => "cyan", -foreground => "black", -command => [$cmd], ); $menu_btn->separator(); } # Add an Exit to the menu list $menu_btn->command(-label => "Exit", -background => "white", -activebackground => "cyan", -foreground => "black", -command => sub { exit }, ); $menu_btn->separator(); MainLoop;

Here's the error when I select any of the menu options except EXIT:
Tk::Error: Undefined subroutine &main::&getA34980Info called at D:/Act +ivePerl/site/lib/Tk.pm line 411

In reply to PERL/Tk and Menu -command option by boblikeperl

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.