Sent: Friday, December 06, 2019 at 11:30 AM
From: "welle ozean" <welleoz...@googlemail.com>
To: "Christopher Chavez" <chrischa...@gmx.us>
Subject: Re: Call perl subroutine from $int->Eval

> Thank you Christopher,

> this is very promising! But, I have no idea how to use it. Let's say I have 
> in my Perl code a subrutine called mySubrutine. How would I call it from 
> within the Eval Tcl code?

I would use something like:

$int->Eval(q/::perl::Eval {mySubroutine()} /)


I'm not an expert on how it works or if it has any significant limitations; it 
seems to work like Perl's built-in `eval` statement in the same scope as the 
`$int->Eval()`. I guess one thing to be careful of is which (if any) string 
delimiters/escaping are used both in Perl and Tcl especially whenever 
`$variables` need to be specified, so that they refer to a Tcl or Perl variable 
(or neither?). For example if using a Perl variable, doing

my $variable = ...;
$int->Eval(qq/::perl::Eval {mySubroutine($variable)} /);

might often behave the same as doing

my $variable = ...;
$int->Eval(q/::perl::Eval {mySubroutine($variable)} /);

but I would prefer the latter usage so that the value of `$variable` isn't 
translated (stringified) from Perl to Tcl and then back to Perl.


Christopher A. Chavez

Reply via email to