in reply to Re^5: passing subroutine references
in thread passing subroutine references

It's static and lexical to two subroutines.

And yes, localizing a var is a trick. Something that confuses most newcomers to Perl. Localizing a whole typeglob so that you could call the newly created closure as if it was an ordinary subroutine doubly so. If you insist on using local(), localize the $move_disk and define the _hanoi() as an ordinary subroutine accessing the package variable $move_disk.

BTW, what was the last time you actually generated a stack trace?

Jenda
Enoch was right!
Enjoy the last years of Rome.

Replies are listed 'Best First'.
Re^7: passing subroutine references
by ikegami (Patriarch) on Sep 21, 2009 at 03:02 UTC

    BTW, what was the last time you actually generated a stack trace?

    I used confess and code analysers on my previous workday.

    define the _hanoi() as an ordinary subroutine accessing the package variable $move_disk.

    Yeah, you could make _hanoi public, but it doesn't buy you anything to do so.

Re^7: passing subroutine references
by ikegami (Patriarch) on Sep 21, 2009 at 03:00 UTC
    <bockquote>

    BTW, what was the last time you actually generated a stack trace?

    I used confess and code analysers on my previous workday.

    define the _hanoi() as an ordinary subroutine accessing the package variable $move_disk.

    Yeah, you could make _hanoi public, but it doesn't buy you anything to do so.