title: Accessing class variables using a variable with the class name in perl
body: <p>I'm wondering how I would go about doing this: </p>
  
  <pre><code>package Something;
  our $secret = "blah";
  
  sub get_secret {
      my ($class) = @_;
      return; # I want to return the secret variable here
  }
  </code></pre>
  
  <p>Now when I go</p>
  
  <pre><code>print Something-&gt;get_secret();
  </code></pre>
  
  <p>I want it to print <code>blah</code>. Now before you tell me to just use <code>$secret</code>, I want to make sure that if a derived class uses <code>Something</code> as base, and I call <code>get_secret</code> I should get that class' secret. </p>
  
  <p>How do you reference the package variable using <code>$class</code>? I know I can use <code>eval</code> but is there more elegant solution?</p>