in reply to Re: bullet proof SLURP file
in thread bullet proof SLURP file

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)

Replies are listed 'Best First'.
Re^3: bullet proof SLURP file
by karlgoethebier (Abbot) on Jan 10, 2018 at 10:20 UTC

    Too bad ;-[. And i need a while to digest the code you provided.

    Thanks and best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help