note
demerphq
<!--
<p><em></em></p>
<code></code>
<i></i>
<b></b>
[ ]
-->
<p>
Yeah I do use this style as well. However it still presents duplication when you want to provide defaults or multiple names or types for options (which rules out a quick <code>key %opts</code>), in fact its worse because you dont have compile time var name checking of the var names if they get out of synch. In other words the connection between destination and source becomes too loose and it becomes really easy to make a subtle error
</p>
<code>
my %opt={verbose=>0,all=>0);
GetOptions(\%opt,'talkative|verbose','everything|all');
</code>
<p>
So what happens if we werent careful and do it like
</p>
<code>
GetOptions(\%opt,'talkative|verbose','all|everything');
</code>
<p>
Oops, now the --all options goes to the wrong place.
</p>
<p>
Anyway, I still would use the %hash style as well for some situations, and as the interface to Getopt::Long is so flexible you can mix the two:
<code>
GetOptions(\%opts,'Debug=i'=>\(my $Debug=0),'verbose','all');
</code>
<p>
And then theres also using subs for the options... Mmm fun!
</p>
<br />
---
<br />
demerphq<br />
<br />
<!--
<hr />
<p>
<strong>• Update: </strong><br />
</p>
-->
<br />
241367
241417