You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Carlos Kassab <ck...@glin.com.mx> on 2003/01/21 04:44:18 UTC

Recursivity with embperl

Hi:

I am working in the eplsite project (eplsite.glin.com.mx), in the news
module we need to do some recursive process to display the comments.

I have a subroutine DisplayKids to display the comments and inside the
subroutine i am calling it and embperl do it very well but just display
the sons. If i have two comments at the same level it is not displayed.
example:

-comment1
 -son of comment 1
  -son of son of comment 1
 -brother of comment 1(this is not displayed)

it seems that embperl is loosing the values for recursive process.

Do  you know a way to do recursive processes with embperl? i am using
embperl 1.3.4

Thank you in advance for your help

Carlos Kassab


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


Re: Recursivity with embperl

Posted by Kee Hinckley <na...@somewhere.com>.
If you don't want to use [* local *], I've on occasion made use of 
the @_ as a variable stack.  Doesn't exactly make for clear code 
though.
-- 

Kee Hinckley - Somewhere.Com, LLC
Business: http://consulting.somewhere.com/
Writings: http://commons.somewhere.com/buzz/

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

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


Re: Recursivity with embperl

Posted by Gerald Richter <ri...@ecos.de>.
>But i still have a question, how can i do to print inside the procedure
>get_factorial without call the subroutine eplprint?

print OUT $a ;

Gerald



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


Re: Recursivity with embperl

Posted by Carlos Kassab <ck...@glin.com.mx>.
Hi:

Thank you for your help. it worked. Below is an example of a recursive
process:

But i still have a question, how can i do to print inside the procedure
get_factorial without call the subroutine eplprint?. If i try to use
embperl code to define the sub ([$ sub get factorial $]), it does not
work.

[$ sub eplprint $]
[-  $c = shift ; -]
[+ $c +]
[$ endsub $]


[*
sub get_factorial 
{
  local $a;
  $a = shift;

  if( $a == 1 )
  {
     &eplprint($a);
     return($a);
  } else {
     &eplprint($a);
     return($a*&get_factorial($a-1));
  }
}
*]

[- $d= 3; $b=&get_factorial($d);-]

 --- "Factorial" of [+ $d +] is [+ $b +]



Thank you 

Carlos Kassab





El mar, 21-01-2003 a las 00:59, Gerald Richter escribió:
> 
> >
> > it seems that embperl is loosing the values for recursive process.
> >
> > Do  you know a way to do recursive processes with embperl? i am using
> > embperl 1.3.4
> >
> 
> If you are using Embperl's [$ sub $] or Execute to do the recursive call you
> need to declare the variables local. In Embperl you can do this with
> 
> [*
> local $foo ;
> local $bar ;
> *]
> 
> Note that in 1.3.4 'my' instead of local does not work (in 2.0 it does)
> 
> Gerald
> 
> 
> -------------------------------------------------------------
> Gerald Richter    ecos electronic communication services gmbh
> Internetconnect * Webserver/-design/-datenbanken * Consulting
> 
> Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
> E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
> WWW:        http://www.ecos.de      Fax:      +49 6133 925152
> -------------------------------------------------------------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org



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


Re: Recursivity with embperl

Posted by Gerald Richter <ri...@ecos.de>.
>
> it seems that embperl is loosing the values for recursive process.
>
> Do  you know a way to do recursive processes with embperl? i am using
> embperl 1.3.4
>

If you are using Embperl's [$ sub $] or Execute to do the recursive call you
need to declare the variables local. In Embperl you can do this with

[*
local $foo ;
local $bar ;
*]

Note that in 1.3.4 'my' instead of local does not work (in 2.0 it does)

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------


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