Subject: | Unhelpful prototype for GetOptionsFromArray |
I had wrapped
Getopt::Long::GetOptionsFromArray
in a function of my own with the same spec, and wanted to pass @_ on to
it. (i.e. the array argument was already in the argument list as $_[0]).
So I naturally wrote
$ret = Getopt::Long::GetOptionsFromArray(@_0);
and was very puzzled when it died with "
Can't use string ("19") as an ARRAY ref while "strict refs" in use at
/usr/lib/perl5/5.8.8/Getopt/Long.pm line 497, <CVSRC> line 2."
Even with the perl debugger I couldn't see what was going on, until I
thought of prototypes, and saw that the function was declared as
sub GetOptionsFromArray($@);
I can sort of see why this was done; but I don't think it's really
helpful. It will let people write the call without ( ), but the cost is
that I had a strange and incomprehensible error, which I could not fix
without looking at the code.
I want to suggest that this prototype should be simplified to '@'. That
is less precise than it need be, but I don't think you'll lose anything
by it.