http://qs321.pair.com?node_id=1215470


in reply to Re: Should I use carp/croak or warn/die
in thread Should I use carp/croak or warn/die

I'm unaware of any recommendation of best practice which says always to use one or the other.

Perl::Critic::Policy::ErrorHandling::RequireCarping, which references page 283 of PBP.

  • Comment on Re^2: Should I use carp/croak or warn/die

Replies are listed 'Best First'.
Re^3: Should I use carp/croak or warn/die
by hippo (Bishop) on May 30, 2018 at 15:21 UTC

    Honestly, I did almost add "but it's probably in PBP somewhere" to my previous post. :-) Thanks for the reference, though.

    Note that even there it's an arbitrary distinction as perlcritic won't moan at newline-terminated warn/die calls.

    $ echo 'package Foo; use strict; use warnings; warn "foo!"; 1;' | perl +critic -3 "warn" used instead of "carp" at line 1, column 40. See page 283 of P +BP. (Severity: 3) $ echo 'package Foo; use strict; use warnings; warn "foo!\n"; 1;' | pe +rlcritic -3 source OK $
Re^3: Should I use carp/croak or warn/die
by SBECK (Chaplain) on May 30, 2018 at 15:30 UTC
    Thanks for the reference. Although I don't agree with all of the recommendations of perl critic, I have learned a lot from reading through it's suggestions. I'll go back and reread this section for sure.