in reply to Carp::Always comeback
G'day ferreira,
++ Thanks for the module update and notification.
"You're invited to give it a try."
I've never used this module previously. It installed without any problems, by the way. I noted in Carp::Always - BUGS the issue that it "... does not play well with other modules which fusses around with warn, die, ...". I have an alias which I use often for testing code snippets; it uses autodie; I wondered if there would be any issues using the two together.
Here's the playing field:
$ uname -a Darwin ganymede.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 +16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64 i386 M +acPro5,1 Darwin $ perl -v | head -2 | tail -1 This is perl 5, version 28, subversion 0 (v5.28.0) built for darwin-th +read-multi-2level $ alias perle alias perle='perl -Mstrict -Mwarnings -Mautodie=:all -E' $ ls not_a_file ls: cannot access 'not_a_file': No such file or directory
I tried a number of tests (mostly based on the code example in your OP) using '-M' and 'use', with different load orders.
$ perle 'use Carp::Always; die "arghh"' arghh at -e line 1. $ perle 'use Carp::Always; sub f { die "arghh" }; sub g { f }; g;' arghh at -e line 1. main::f() called at -e line 1 main::g() called at -e line 1 $ perle 'use Carp::Always; sub f { open my $fh, "<", "not_a_file" }; s +ub g { f }; g;' Can't open 'not_a_file' for reading: 'No such file or directory' at -e + line 1 main::open(GLOB(0x7feaba80e750), "<", "not_a_file") called at -e l +ine 1 main::f() called at -e line 1 main::g() called at -e line 1 $ perl -Mstrict -Mwarnings -MCarp::Always -Mautodie=:all -E 'sub f { o +pen my $fh, "<", "not_a_file" }; sub g { f }; g;' Can't open 'not_a_file' for reading: 'No such file or directory' at -e + line 1 main::open(GLOB(0x7ff52b80d950), "<", "not_a_file") called at -e l +ine 1 main::f() called at -e line 1 main::g() called at -e line 1 $ perl -Mstrict -Mwarnings -Mautodie=:all -MCarp::Always -E 'sub f { o +pen my $fh, "<", "not_a_file" }; sub g { f }; g;' Can't open 'not_a_file' for reading: 'No such file or directory' at -e + line 1 main::open(GLOB(0x7f955100d950), "<", "not_a_file") called at -e l +ine 1 main::f() called at -e line 1 main::g() called at -e line 1 $ perl -Mstrict -Mwarnings -E 'use autodie ":all"; use Carp::Always; s +ub f { open my $fh, "<", "not_a_file" }; sub g { f }; g;' Can't open 'not_a_file' for reading: 'No such file or directory' at -e + line 1 main::open(GLOB(0x7f7f6480d950), "<", "not_a_file") called at -e l +ine 1 main::f() called at -e line 1 main::g() called at -e line 1 $ perl -Mstrict -Mwarnings -E 'use Carp::Always; use autodie ":all"; s +ub f { open my $fh, "<", "not_a_file" }; sub g { f }; g;' Can't open 'not_a_file' for reading: 'No such file or directory' at -e + line 1 main::open(GLOB(0x7fb6fa032b50), "<", "not_a_file") called at -e l +ine 1 main::f() called at -e line 1 main::g() called at -e line 1 $ perl -Mstrict -Mwarnings -E 'use autodie ":all"; sub f { open my $fh +, "<", "not_a_file" }; sub g { f }; g;' Can't open 'not_a_file' for reading: 'No such file or directory' at -e + line 1 $ perl -Mstrict -Mwarnings -E 'use Carp::Always; sub f { open my $fh, +"<", "not_a_file" }; sub g { f }; g;' $ perl -Mstrict -Mwarnings -E 'sub f { open my $fh, "<", "not_a_file" +}; sub g { f }; g;' $ perl -E 'sub f { open my $fh, "<", "not_a_file" }; sub g { f }; g;' $
While that in no way tests the full fucntionality of autodie against Carp::Always; it was sufficient for me to update my alias:
$ alias perle alias perle='perl -Mstrict -Mwarnings -Mautodie=:all -MCarp::Always -E +'
And that now works as expected:
$ perle 'sub f { open my $fh, "<", "not_a_file" }; sub g { f }; g;' Can't open 'not_a_file' for reading: 'No such file or directory' at -e + line 1 main::open(GLOB(0x7fb28e80f750), "<", "not_a_file") called at -e l +ine 1 main::f() called at -e line 1 main::g() called at -e line 1
So, thanks again and, if I do encounter any problems in the future, I'll let you know.
— Ken
|
|---|