http://www.perlmonks.org?node_id=1203043


in reply to understand and prevent 'Out of memory!' during sub recursion

This is why I almost never use "terse" code like this – like map. You can't instantly tell what the code is doing, and you really don't have any way to break-out. (That's not what map is intended for.) The snake eats its own tail until it grows too fat and dies. Whereas, a very short subroutine would accomplish the same task and do so with clarity. There would be no meaningful difference in execution time. Terseness is really not your friend at all. Clarity, and maintainability, is.
  • Comment on Re: understand and prevent 'Out of memory!' during sub recursion

Replies are listed 'Best First'.
Re^2: understand and prevent 'Out of memory!' during sub recursion
by Eily (Monsignor) on Nov 09, 2017 at 16:28 UTC

    Well here Discipulus is trying to learn, so I think it's a legimate case for trying new and unusual ways. Also, "I wouldn't have done it like that" isn't very helpful when someone is asking for help correcting and understanding their mistakes.

Re^2: understand and prevent 'Out of memory!' during sub recursion
by hippo (Bishop) on Nov 09, 2017 at 16:46 UTC
    You can't instantly tell what the code is doing ... a very short subroutine would accomplish the same task

    Except that Discipulus is already using a very short subroutine. So you are right in that you can't tell what the code is doing because you didn't spot that. map is perfectly fine - perhaps even ideal - in this context.