in reply to Re^2: How to perform a subroutine run in cpan Tk::ExecuteCommand module
in thread How to perform a subroutine run in cpan Tk::ExecuteCommand module

Calling external programs is done by system or qx/backticks.

If you want to call an external program when a button is clicked, put that call to the external program in your callback:

my $cmd= sub { my $commandline= "my/external/program --foo=param1 --bar=param2"; system($commandline) == 0 or warn "Couldn't launch [$commandline]: $!/$?"; };
  • Comment on Re^3: How to perform a subroutine run in cpan Tk::ExecuteCommand module
  • Download Code

Replies are listed 'Best First'.
Re^4: How to perform a subroutine run in cpan Tk::ExecuteCommand module
by Janish (Sexton) on Jun 25, 2014 at 08:11 UTC

    I updated the code as you suggested, but yet it still doesn't work out for me. It now placing the random number "CODE(0x78efb0)" within the entry.

      I'm sorry - I had not read the documentation for Tk::ExecuteCommand.

      $cmd is only allowed to be a shell command. So you can only use the following:

      my $cmd= "/nfs/work/testing123.pl -text text"; $ec->configure( -command => $cmd ); $ec->update;

      Note the double quotes instead of the backticks.

        Thanks Corion, By putting the whole execution line in $cmd, it works, but what I'm looking for is if the module can works on subroutine instead of a command. As there and something else extra I would like to put inside the subroutine before the one liner external command be executed. The Perl external script is part of the job inside my subroutine. Can this be done?

Re^4: How to perform a subroutine run in cpan Tk::ExecuteCommand module
by Janish (Sexton) on Jun 25, 2014 at 08:14 UTC

    I have updated my code as you suggested, but yet it still not work out for me. It is now placing a random generated number (CODE(0x78efb0) within the entry.