Inline::Tcl - Write Perl subroutines in Tcl.
use Inline Tcl => <<END; set asdf 2 proc dummy { val } { puts "Dummy says \$::asdf + \$val = [expr \$::asdf + \$val]" incr val return [expr \$::asdf + \$val] } END $result = dummy(1); print "But returned $result\n";
The output from this program is: Dummy says 2 + 1 = 3 But returned 4
The Inline::Tcl module allows you to put Tcl source code directly "inline" in a Perl script or module. A Tcl interpreter is loaded and the Tcl code is interpreted, then Perl asks the Tcl interpreter which global procedures have been defined. Those functions are made available to your Perl program as if they had been written in Perl.
Inline::Tcl
The process of interrogating the Tcl interpreter for globals only occurs the first time you run your Tcl code. The namespace is cached, and subsequent calls use the cached version.
Inline::Tcl is based primarily on the Inline::Python module.
Inline::Python
This section will explain the different ways to use Inline::Tcl.
use
The most basic form for using Inline::Tcl is:
use Inline Tcl => 'Tcl source code';
Of course, you can use Perl's "here document" style of quoting to make the code slightly easier to read:
use Inline Tcl => <<'END'; Tcl source code goes here. END
The source code can also be specified as a filename, a subroutine reference (sub routine should return source code), or an array reference (array contains lines of source code). This information is detailed in 'perldoc Inline'.
This is an ALPHA release of Inline::Tcl. Further testing and expanded support for other operating systems and platforms will be a focus for future releases. It will probably only run on linux. If it works for you, let me know.
For information about using Inline, see Inline.
Inline
For information about other Inline languages, see Inline-Support.
Inline::Tcl's mailing list is inline@perl.org
The subscribe, send email to inline-subscribe@perl.org
When reporting a bug, please do the following:
- Put "use Inline REPORTBUG;" at the top of your code, or use the command line option "perl -MInline=REPORTBUG ...". - Run your code. - Follow the printed instructions.
Ryan Sadler <RRS@cpan.org>
Brian Ingerson <INGY@cpan.org> is the author of Inline, Inline::C and Inline::CPR. Neil Watkiss <NEILW@cpan.org> is the author of Inline::Python.
Copyright (c) 2001, Ryan Sadler.
All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License.
(see http://www.perl.com/perl/misc/Artistic.html)
To install Inline::Tcl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Inline::Tcl
CPAN shell
perl -MCPAN -e shell install Inline::Tcl
For more information on module installation, please visit the detailed CPAN module installation guide.