in reply to Writing TIMTOWDI-friendly CPAN Modules
Prototypes are not so bad, you don't need them most of the time, but in some ocassions they provide the syntactic sugar required to make a function much more friendly. I specially like the & proto that allows to write functions that work as grep {...} @foo;. My advice is: use them only when there is an obvious gain.
Carp::croak is your only way to report fatal errors in modules (well, except internal errors that should be reported with die), but Carp::carp is not so useful. If some function accepts optional arguments then it's ok for the user to not pass them and no warning is required; on the other hand, if some required arguments are missed, croak!.
Anyway, if you use Carp::carp, remember to let the user deactivate the warnings using warnings::register and warnings::enabled() in your module.
|
|---|