title: Creating container class in Perl (using Moose)
body: <p>I'm trying to create a container class in Perl called Gene, which will store objects created by another class 'Cis' (so for example Gene1 will store Cis1a Cis1b Cis1c, and Gene2 will store Cis2a Cis2b Cis2c). This is what I have so far:    </p>
  
  <pre><code>package Gene;
  
  use Moose;
  
  has 'bindingsites'=&gt;(
  isa=&gt;'ArrayRef[Cis]',
  is=&gt;'rw',
  default=&gt;sub{[]},
  
  
  package Cis;
  use Moose;
  
  has 'gene'=&gt;(isa=&gt;'Gene', is=&gt;'rw', weak_ref =&gt;1);
  </code></pre>
  
  <p>I was looking at one of the <a href="http://search.cpan.org/~doy/Moose-2.0401/lib/Moose/Cookbook/Basics/Recipe4.pod" rel="nofollow">Moose Recipes</a> and was trying to use that, but I'm not entirely sure it is what I am looking for. Using that I had written something like in the Gene class:</p>
  
  <pre><code> sub Build{
   my(&amp;self,$params)=@_;
   foreach my $bindingsite(@{$self-&gt;bindingsites}){
     $gene-&gt;bindingsite($self)}}
  </code></pre>
  
  <p>but I'm not sure that is what I need to do, and how each Gene class will know which Cis objects to store.</p>
  
  <p>Thanks in advance for any help</p>