develooper Front page | perl.fwp | Postings from March 2003

Re: golf tee puzzle

Thread Previous | Thread Next
From:
Steffen Mueller
Date:
March 18, 2003 05:44
Subject:
Re: golf tee puzzle
Quantum Mechanic wrote:
[...]

> So I think my problem is a memory leak
> somewhere. There is one main recursive routine, which
> creates a number of "my" variables. I suspect that I'm
> somehow keeping a reference to a variable that I
> shouldn't be, and that's causing my memory problem. 

I suggest you stay as far away from recursion in Perl as possible. At 
least if you are memory or CPU limited. Perl keeps the lexical scope on 
a stack until you return from the recursion. If it's deep, you're, well, 
in deep trouble.

If you're using tail recursion, you may get rid of the problem by using 
"goto sub". (perldoc -f goto)
[...]

HTH,
Steffen
-- 
sub'_{q} tsuJ}}_();sub's{seek+DATA,0,0}sub'p{print&_}sub'r{reverse$_[0]}
@_=(('')x2,split"  ",<DATA>);s!!&s,$_=<DATA>;s/}.*?}/$_[$s+1]/
if$s;s/(}.*?})/r$1/e;eval$_;p,$s++!efor@_[0..3];
__DATA__
} rehtona}  } lreP}  },rekcah}


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About