in reply to How is redefining a sub internally done?

  Which makes sense, because a symbol can't be redefined if it doesn't exist.

But if you throw in an undef &g; before the delete, it prints 22. Why is that?

Replies are listed 'Best First'.
Re^2: How is redefining a sub internally done?
by LanX (Saint) on Sep 26, 2024 at 23:32 UTC
    I can only speculate, like in my last update, that as soon as a sub has "weird" flags, the symbol table acts as fallback.

    But I couldn't find any informations in the docs, we need to wait for someone knowing the internals.

    Obviously is deleting a symbol, like already demonstrated, an efficient way to sabotage the whole redefine mechanism.

    Update

    Well, I should have added that undef &g is changing the sub considerably. Use Devel::Peek with a coderef to see by yourself.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery