perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From PILCH Hartmut <...@a2e.de>
Subject erratic effect of input key in Execute (more)
Date Sun, 26 Mar 2006 02:40:55 GMT
I am trying to move subroutines to external packages that are shared between
Embperl applications and normal commandline Perl programs, but this requires
that messages can be written either by a commandline program to STDERR or by
Embperl to the web session, depending on the context of invocation.

At

	http://www.ecos.de/embperl/pod/doc/Config.-page-1-.htm#sect_3

I find an example of how to invoke the Embperl parser from a Perl program, and
indeed I can make this work in a simple script, like

	 [- $msg = 'hello world' -]
	 <h3>[- Embperl::Execute({input=>\$msg}) -]</h3>

However, when I repeatedly invoke this with different messages, e.g.

  [- $msg = 'allo mir'
     sub hello {
	local $msg = shift || 'hello world' ; 
	Embperl::Execute({input=>\$msg});
		}
   -]
  [$sub hallo$]
  [- $msg = shift || 'hallo welt';Embperl::Execute({input=>\$msg}) -]
  [$endsub$] 
  <h3>1 [- hello('hello world') -]</h3>
  <h3>2 [- Embperl::Execute({input=>\$msg}) -]</h3>
  <h3>3 [- hallo('hallo welt') -]</h3>


where 'hello' and 'hallo' are subroutines that just invoke the same as above,
I always get the same message three times.  

If I define one of the subroutines is defined as follows

  $msg2 = 'hello world' ;

  sub hello {
      local $s = shift;
      $s = $msg2 unless $s;
      Embperl::Execute({input=>\$s});
      Embperl::Execute({input=>\$msg2});
  };

all I get is a repetition of the same buffer twice.  The contents of
\$msg, \$s and \$msg2 appear to be unified.

It is as if Execute was using the same memory buffer for all three invocations
and as if that memory buffer was written in one run and used in another.

I can not predict which of the three messages makes it, but this apparently
depends on the length of my program file.  If I add a meaningless comment
line, another one of the three message strings may make it.  As long as I
don't edit the file, repeated invocation leads to the same result.

Setting

    mtime=>1

or

    mtime=>undef

doesn't change this behaviour either.

If I define an Embperl subroutine:

	[$sub allo$]
	[- $msg3 = 'allo mir';Embperl::Execute({input=>\$msg3}) -]
        [$endsub$] 

this produces no output at all.

Likewise, I tried to use Embperl::Object::Execute, but that just produced no
output at all.  I found that strange, given that the PerlHandler used by my
Embperl installation is Embperl::Object, not Embperl.

You may find more on this at

    http://a2e.de/phm/adv/embperl

as I continue to explore this riddle.

I'm using the Embperl 2.1.

--
Hartmut Pilch			   http://a2e.de/phm/adv/embperl






---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message