Shouldn't something like this catch them all?
Doesn't look like it, sorry :-( A look at the Path::Tiny source shows it seems to do no error checking on the reads at all.
#!/usr/bin/env perl use warnings; use strict; use Data::Dump; use Path::Tiny; use Try::Tiny; use autodie qw(:all); package ReadFail { use parent 'Tie::Handle::Base'; sub READLINE { $! = 1; return } sub READ { $! = 1; return undef } } my $orig = \&Path::Tiny::filehandle; my $wrap = sub { ReadFail->new( $orig->(@_) ) }; { no warnings 'redefine'; *Path::Tiny::filehandle = $wrap } try { dd "slurp_utf8", path('mydata.txt')->slurp_utf8 } catch { dd "error", $_ }; __END__ ("slurp_utf8", undef)
In reply to Re^2: bullet proof SLURP file
by haukex
in thread bullet proof SLURP file
by leszekdubiel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |