The IO::File, IO::Socket::INET modules have some advantages over directly using perl's built-in IO functions, such as having explicit syntax to flush a handle.
However, they seem to have some disadvantages over the built-in IO functions. For example, as far as I can tell they can't be combined with the autodie module to raise exceptions on failure, so I'm finding myself having to write overall more boilerplate code to handle failures than I was with built-in functions.
Is there a way to combine the two, or some other modules that have the combined functionality? I've noticed some limited-purpose IO modules, such as File::Slurp, do allow more flexible error handling.
I'm writing module code, and ideally, the solution should work all the way back to perl 5.10.0.
Have you looked at Path::Tiny? The syntax is different but it does throw exceptions.
E.G.
use Path::Tiny;
path('/non/existent/file')->openr;
will die with a Path::Tiny::Exception object (assuming you don't have such a file)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With