perlcritic投诉以下代码,一些样板DBI的东西工作完美,应该
croak
而不是
die
:
# Connect to database my $db_handle = DBI->connect( $url,$user,$password ) or die $DBI::errstr;
所有这一切,虽然死了似乎对我来说很好.
我会想到一个武士的Perl战士,呱呱呱呱.able able able able when when……..笑话分开
为什么要cro ak而不是死?
没有注意perlcritic’s的建议有什么后果?
解决方法
从
http://www.perlmonks.org/?node_id=685452
You use die when the error is something you or your code didn’t do right. You use croak when it’s something your caller isn’t doing right. die “error: $!” indicates the error is on the line where the error occured. croak “error: $!” indicates the error is on the line where the caller called your code.