in reply to Re: exists(&subname) causes strange autovivification problem
in thread exists(&subname) causes strange autovivification problem

Can someone explain this syntax to me? I understand what it's doing but not why it's doing it.
no if $ARGV[0], "autovivification";

Replies are listed 'Best First'.
Re^3: exists(&subname) causes strange autovivification problem
by afoken (Chancellor) on Nov 08, 2024 at 21:33 UTC
    no if $ARGV[0], "autovivification";

    no MODULE LIST; is like use MODULE LIST, but calls a different method (unimport(LIST) instead of import(LIST)) - see no

    if is a module named if, not your usual if, but the same idea. The if module accepts a condition, a module, and a (possible empty) argument list. If the condition is true, the if module loads the module passed after the condition and calls its import() or unimport() method.

    All that glued together: if $ARGV[0] is true, call the unimport() method of autovivification. This disables autovivification if $ARGV[0] is true, at compile time.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      Awesome, Thanks! Never heard of the "if" module but it seems pretty handy.