16.18. Interapplication Communication

You can use the send command to have Perl/Tk (and even Tcl/Tk) applications communicate back and forth. The arguments include an application to talk to and the command to execute in that application.

$widget->send("application" => callback);

You can also specify the option -async, which will return control immediately instead of waiting for the callback to execute.

By default, your application will return an error to another application trying to communicate with it. If you want to actually receive communications from other applications, define Tk::Receive($widget, "command") and be very careful with what you do with the command string. Allowing any application to send unknown commands to your application can be dangerous.

When doing interapplication communication, it is a good idea to run your Perl script with the -Tswitch, which forces taint checking.

Get Learning Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.