title: perl object and attribute
body: <p>I am trying to create perl object (and its associated attributes), based on some conditions (for example the version of the object), a certain attribute is not needed (or invalid otherwise). How do I create the object, without having to specify the object twice (once for each condition). </p>
  
  <pre><code>my $obj = myobject-&gt;new (
  attr1 =&gt; value1,
  attr2 =&gt; value2,
  attr3 =&gt; valuen,
  )
  </code></pre>
  
  <p>Can I for example, define a variable and assign it different value based on the condition? Like this:</p>
  
  <pre><code>my $attribute = (condition)? "":'attr4 =&gt; value4';
  </code></pre>
  
  <p>and simply define the object like this:</p>
  
  <pre><code>    my $obj = myobject-&gt;new (
      attr1 =&gt; value1,
      attr2 =&gt; value2,
      attr3 =&gt; valuen,
      $attribute,
      )
  </code></pre>
  
  <p>This obviously will err out. But you get my idea. How do I make this work?</p>