use strict;
use Tcl;

my $int = new Tcl;

$tcl::foo = 'qwerty';
my $x = "some perl scalar var";
$int->export_to_tcl(subs_from=>'tcl',vars_from=>'tcl');
$int->export_to_tcl(subs=>{lala=>sub{print "lala!\n"}}, namespace=>'');
$int->export_to_tcl(vars=>{foo=>\$x}, namespace=>'');
$int->export_to_tcl(subs_from=>''); # this will bind sub named sub1 below

$int->Eval(<<'EOS');

package require Tk

button .b1 -text {a fluffy button} -command perl::fluffy_sub
button .b2 -text {a foo button} -command perl::foo
button .b3 -text {lala} -command lala
entry .e -textvariable perl::foo
pack .b1 .b2 .b3 .e
focus .b2
perl::sub1

tkwait window .
EOS

sub tcl::fluffy_sub {
    print "Hi, I am a fluffy sub\n";
}
sub tcl::foo {
    print "Hi, I am foo\n";
    $tcl::foo++;
}
sub sub1 {
    print "Hi, I am sub1!\n";
}

