Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^5: sub calls and memory use

by LanX (Saint)
on Nov 16, 2019 at 15:03 UTC ( [id://11108788]=note: print w/replies, xml ) Need Help??


in reply to Re^4: sub calls and memory use
in thread sub calls and memory use

In Perl you are generally better off translating tail calls to loops. They are way faster and easier to understand.

You never explained your use case, but your example is easily translated with redo

Concerning your memory growth, we'd need to know how you declared the "global var".

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^6: sub calls and memory use
by Anonymous Monk on Nov 16, 2019 at 15:35 UTC
    In Perl you are generally better off translating tail calls to loops.

    I replaced that recursive sub with a while loop and yeah, makes more sense, less code, and no memory bomb. ThanX

    Concerning your memory growth, we'd need to know how you declared the "global var".

    Sorry I was mistaken about that :-/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11108788]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-19 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found