Book HomeMastering Perl/TkSearch this book

13.20. 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, "IPC with send".

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, "IPC with send" for complete details and working programs.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.