Global? There ain't any global sir.

Global to all calls to hanoi. External? Non-local? Yet highly coupled.

And _hanoi(@_); would work just as well

That's what I said.

while your tricks with local are unavoidable.

How is localising a var "a trick"? Dealing with package vars is a necessity in Perl, and the first thing you need to know is how to localise them.

It is avoidable, but it's messy and requires a trick to avoid a memory leak.

my $_hanoi; # \ Messy line break $_hanoi = sub { # / ... $_hanoi->(...); # Relatively messy syntax ... }; $_hanoi->(...); undef $_hanoi; # Messy hack to avoid mem leak.

Using local actually cleans up a whole of mess.

Besides the problem is not the local itself, but the typeglob handling.

"The typeglob handling" makes "setting a typeglob" sound falsely ominous. It's a manufactured problem.

What debugging complexities are you speaking of?

The removal of a stack frame creates lying stack traces, not just to users but to debugging tools.


In reply to Re^5: passing subroutine references by ikegami
in thread passing subroutine references by joe76

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.