Is it better to croak() or to die() when something bad happens in Perl?
问题 perlcritic complaints that the following code, some boilerplate DBI stuff that works perfectly fine, should croak instead of die: # Connect to database my $db_handle = DBI->connect( $url, $user, $password ) or die $DBI::errstr; All this, while die seems to work fine for me. I would think for a samurai Perl warrior, croak is less honorable than actually die when things go awry. Jokes apart Why should I croak instead of die ? What are the consequences of not heeding perlcritic's advice? 回答1: