Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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


In reply to Re: Carp::Always comeback [tests with autodie] by kcott
in thread Carp::Always comeback by ferreira

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-25 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found