perlquestion
neilwatson
<p>Greetings,</p>
<p>I have a moose question. I'm still new to moose. Normally I would pass
parameters to a new object thusly.</p>
<code>
my $ob = MyModule->new(
colour => $colour,
shape => $shape,
);
</code>
<p>Suppose that colour and shape are arguments and that they are optional. It seems that if no argument is given via my program the value is ''. This seems to confuse my classes on the moose side where it fails to set the default. My thought was to build the parameter hash before hand so as to pass only the arguments that are defined.</p>
<code>
if ( $colour ) { $param{'colour'} = $colour };
if ( $shape ) { $param{'shape'} = $shape };
my $ob = MyModule->new( %param );
</code>
<p>I tried this but nothing seems to make it to moose. Am I on the right track? Is there better way?</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-104468">
<p>
Neil Watson<br>
<a href="http://watson-wilson.ca">watson-wilson.ca</a>
</div></div>