in reply to Re^2: Why not use a local variable for $self in Moose?
in thread Why not use a local variable for $self in Moose?

No, your $self in global scope is just one variable that then gets overwritten every time you instantiate a new object. The old one automatically gets DESTROYed at that time.

Maybe consider just creating two objects of the same such class and watch what happens.

Replies are listed 'Best First'.
Re^4: Why not use a local variable for $self in Moose?
by nysus (Parson) on Oct 19, 2018 at 07:14 UTC

    OK, I think I get it. There can only be one $my_package::self variable in the compiled code at a time.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      >  $my_package::self

      $self doesn't belong to a package, it's private (not local ) in the file scope, since you declared it with my.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice