Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Should I use carp/croak or warn/die

by hippo (Bishop)
on May 30, 2018 at 15:09 UTC ( #1215469=note: print w/replies, xml ) Need Help??


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

Personally speaking I prefer to use carp/croak when it's the fault of the caller and warn/die when it's the fault of the current sub. That way the message is appropriately relevant. I'm unaware of any recommendation of best practice which says always to use one or the other.

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

Replies are listed 'Best First'.
Re^2: Should I use carp/croak or warn/die
by haukex (Bishop) on May 30, 2018 at 15:11 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 $
      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1215469]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2022-01-21 17:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (59 votes). Check out past polls.

    Notices?