:StdArgs suggest to me that the argument names are somehow standard. Given that it's the parsing of the arguments that's being standardised, perhaps :StdParse, or :ParseArgs, or :AutoParse, or something like that?
It's occured to me that it would be really nice if the :InitArgs approach could be generalised for multiple subs.
Change :InitArgs to :ArgSpec, since this is now an argument specification hash for multiple subs.
Then, make the top level hash keys sub names (so everything else moves down a level), and use a :ParseArgs attribute on subs to indicate that they should be looked up in this hash. Then you could write something like this.
my %args :ArgSpec = (
'init' => {
'MY_PARAM' => ...
},
'some_sub' => {
'OTHER_PARAM' => ...
},
);
sub init :Init { ... }
sub some_sub :ParseArgs { ... }
sub other_sub { # parse args by hand ... }
Or, you could keep the arg spec declaration near the sub, by building up the :ArgSpec hash as you go down the file.
my %args :ArgSpec = (
'init' => {
'MY_PARAM' => ...
},
);
sub init :Init { ...}
$args{'some_sub'} = {
'OTHER_PARAM' => ...
},
);
sub some_sub :ParseArgs { ... }
I've not played much with Perl's attributes, so I don't know how feasible this is.
Of course, they may come a point where it's just esaier to pull in Params::Validate and be done with it.