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]

   $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.

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.

Using the Inline::Tcl Module

Inline::Tcl is based primarily on the Inline::Python module.

This section will explain the different ways to use Inline::Tcl.

The Basics: Functions

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.


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.

For information about other Inline languages, see Inline-Support.

Inline::Tcl's mailing list is

The subscribe, send email to


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 <>

Brian Ingerson <> is the author of Inline, Inline::C and Inline::CPR. Neil Watkiss <> 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.