Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
I think the title says it all, but:
--
- if I've written a sub or module which expects, say, three variables to be passed to it, what should it do when it gets two?
- What if it gets four?
- What's the correct position on whether it should die, warn, or just return an error message?
- How detailed should the error message be? Should I say:
- Wrong number of parameters! I need three!
- Wrong number of parameters! Correct syntax is my_sub($name,$phone,$address)
- Wrong number of parameters! Correct syntax is my_sub($name,$phone,[$address|@address]) -- for instance, if one of the parameters can be an array or a scalar
- Wrong number of parameters! Correct syntax is my_sub($name,$phone,$address)
- Wrong number of parameters! See documentation!
--
($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
Back to
Seekers of Perl Wisdom