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

Thanks for your reply. I'm newbie, and yes, I tried to print out the $cmd, it print out nothing. Is that possible to call subroutine from the $ec->configure(-command => ) line?

I wonder how people do if they want to execute external program which read wrapper (text in my case) with this module, as for now my end it only works with single liner command.

  • Comment on Re^2: How to perform a subroutine run in cpan Tk::ExecuteCommand module

Replies are listed 'Best First'.
Re^3: How to perform a subroutine run in cpan Tk::ExecuteCommand module
by Corion (Patriarch) on Jun 25, 2014 at 07:50 UTC

    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]: $!/$?"; };

      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.

      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.