As a module author you can't use $! to signal your module's errors. The list of possible values of $! is very restricted and is OS dependent. Try this for yourself, you can assign a small integer to $! and get the OS's error message, but you can't assign an adhoc message to the variable.
Your module has to use a different variable or die() with the error message.
Always code as if the guy who ends up maintaining your code
will be a violent psychopath who knows where you live.
-- Rick Osborne