@PERL[expression] definition?

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
According to TakeCommand Help v.11:

@PERL[expression] : Executes the specified Perl expression (requires Active State Perl 5.10).
It's probably an artifact of my ignorance but I can't find answers for the following questions.

  1. Does @PERL block until expression is evaluated? i.e. Does TakeCommand/TCC wait until the Perl expression is evaluated?
  2. What return values (if any) are provided by @PERL?
TIA for any reference to a more complete definition of @PERL or any examples of usage. (I'm most baffled by Item 2! ;) )
 
#2
definition?

On Wed, 04 Nov 2009 21:40:43 -0600, Bob Chapman <> wrote:

|1. Does @PERL block until expression is evaluated? i.e. Does TakeCommand/TCC wait until the Perl expression is evaluated?
|2. What return values (if any) are provided by @PERL?

Being a variable function, @PERL[] will be embedded in a TCC command. The
variable function will be evaluated, it's value substituted in the command line,
and the command executed. The actual value of the variable function will
typically be a number returned by PERL indicating success or failure. Usually
one is interested in the effect of eveluating @PERL[] rather than its "value".
I'm confident you'll get better explanations. Example:

Code:
v:\> set rv=%@perl[$a = 'rekcaH lreP rehtonA tsuJ'; $a = reverse($a);
printf "$a\n"]

Just Another Perl Hacker

v:\> echo %rv
1
--
- Vince
 
#3
Re: @PERL definition?

The actual value of the variable function will typically be a number returned by PERL indicating success or failure.
Thanks for the reply!
Experimentation (for at least one case ;)) suggests that @PERL will return the value of a perl expression provided that the value is an integer (and with the assumption that 'false' is returned as '0'):
Code:
> echo ^|%@perl[$a='aaaabcccdd';$a=~s/z//g;]^|
|0|
> echo ^|%@perl[$a='aaaabcccdd';$a=~s/a//g;]^|
|4|
> echo ^|%@perl[$a='aaaabcccdd';$a=~s/b//g;]^|
|1|
> echo ^|%@perl[$a='aaaabcccdd';$a=~s/c//g;]^|
|3|
> echo ^|%@perl[$a='aaaabcccdd';$a=~s/d//g;]^|
|2|
However, since any return value for @PERL is AFAIK undocumented, I don't know if this behavior is an anomaly or if it can be expected for other perl expressions returning integers. :confused: