in reply to Writing TIMTOWDI-friendly CPAN Modules
Parameter checking is probably less useful than you may think - especially in perl where everything can be anything.
Imagine that your function says it takes a file handle. Do you check that you got a GLOB reference? Or do you check for an IO::File? How about if the user finds a way that your function could be useful in a scenario where the data is coming in via IO::Socket? Or that the data is generated in memory via IO::Scalar? Or maybe there's some real dirty trick, and I find a way to create a tie'd scalar or something? All of these will work, yet your code only allows a subset for what really boils down to an arbitrary (and underinformed) reason.
(I've recently been bitten by the unexpected behaviour of File::Copy only working if the source file is really a file.)
Since perl is so good at doing what the user expects, take advantage of it, and let perl do the work.
|
|---|