Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am using ActiveState's perltray application to make a, well, uh, perl tray application. Does anyone know if and/or how to pass variables to sub routine calls in menu items like ["Do Something", \&DoSomethingSub ]

Replies are listed 'Best First'.
Re: Pass Variables in PerlTray script
by Thelonius (Priest) on Mar 14, 2003 at 15:52 UTC
    Without the benefit of having tried perltray, it looks like this should work:
    ["Do Something", sub { DoSomethingSub($a, $b, $c) } ]
      Yes, that should work. You can also use the string form:
      ["Do Something", 'DoSomethingSub($a, $b, $c)']
      This string will get evaluated when you execute the menu option. Therefore you should only use package variables in the string, as lexicals will be out of scope at the point it is evaluated. And be careful to use single quotes on the string to make sure that the variables are not interpolated into the string at the time the menu is constructed.