O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. For complete details, see Chapter 20.

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 careful what you do with the command string. Allowing any application to send unknown commands to your application can be dangerous. Use the interps method to get a list of valid application names.

When engaging in interapplication communication, it is a good idea to run your Perl script with the -T switch, which forces taint checking. Again, see Chapter 20 for complete details and working programs.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required