title: Can one pass Perl object references between modules?
body: <p>Example code:</p>
  
  <h3>testClass1.pm</h3>
  
  <pre><code>package testClass1; 
  {
  my $testClass2Ref;
  
  sub new
  {
      my($class) = shift;
      $testClass2Ref= shift;
      bless $self, $class;
      return $self;}
  }
  
  sub testRef
  {
      $testClass2Ref-&gt;testRef;
  }
  }
  </code></pre>
  
  <h3>testClass2.pm</h3>
  
  <pre><code>package testClass2; 
  {
  
  sub new
  {
      my($class) = shift;
      bless $self, $class;
      return $self;}
  }
  
  sub testRef
  {
      print "Test 2";
  }
  }
  </code></pre>
  
  <h3>test.pl</h3>
  
  <pre><code>use testClass1;
  use testClass2;
  
  my $testClass2 = testClass2-&gt;new();
  my $testClass1 = testClass2-&gt;new($testClass2);
  $testClass1-&gt;testRef;
  </code></pre>
  
  <p>When I try call <code>$testClass1-&gt;testRef</code>, <code>$testClass2Ref=undef</code>.</p>
  
  <p>How can I pass reference on the object from parent?</p>
  
  <h3>Update</h3>
  
  <p>Oh, sorry, I missed string in example's constructors.</p>
  
  <pre><code>sub new
  {
      my($class) = shift;
      $testClass2Ref = shift;
      my $self    = {name=&gt;'testClass1'};
      bless $self, $class;
      return $self;
  }
  </code></pre>
  
  <p>This test is working, but Eclipse debugger show this variables as 'undef'. </p>
  
  <p>Thanks for your help.</p>