title: Perl class attribute inheritance
body: <p>I have class attribute, e. g., counter of created objects in some base class,</p>
  
  <pre><code>package A;
  our $counter = Counter-&gt;new; # not just a counter in fact, so initialization code should be inherited by descendants as well
  
  sub new {
      $counter++;
      bless {}
  }
  sub get_counter {
      $counter
  }
  
  package B;
  use base 'A';
  
  package main;
  B-&gt;get_counter();
  </code></pre>
  
  <p>I want package B to have his own copy of this class attribute (e. g., counting objects of B class only), and all inherited methods from package A should deal with this copy. What is the correct way to implement this in plain perl and in Moo/Moose? Seems like MooX::ClassAttribute can not be inherited.
  One ugly solution found is to repeat attribute initialization code in each descendant and use symbolic dereference like ${"${class}::counter"} in ancestor's methods to access this attribute with actual package name. But seems like there should be more elegant way.</p>