#!/usr/bin/env perl use warnings; use strict; use IPC::Run3::Shell ':FATAL'; use Try::Tiny; { package Runner; BEGIN { our @ISA = ('IPC::Run3::Shell::Autoload') }; sub new { bless {}, shift }; sub cat { my ($self,$filename) = @_; open my $fh, '<', $filename or die "cat $filename: $!"; while (<$fh>) { print "cat: $_"; } close $fh; } } my $r = Runner->new; $r->cat('/tmp/test.txt'); $r->tac('/tmp/test.txt'); try { $r->cat('/tmp/notexist'); } catch { warn "Failed: $_"; }; try { $r->tac('/tmp/notexist'); } catch { warn "Failed: $_"; }; __END__ cat: Foo cat: Bar cat: Quz Quz Bar Foo Failed: cat /tmp/notexist: No such file or directory at shell.pl line 13. tac: failed to open ‘/tmp/notexist’ for reading: No such file or directory Failed: Command "tac" failed: exit status 1 at shell.pl line 31.