Perl 中的 confess 函式


Perl 中的 confess 函式類似於 cluck;它會呼叫 die,然後列印一直到原始指令碼的堆疊跟蹤。

package T;
require Exporter;
@ISA = qw/Exporter/;
@EXPORT = qw/function/;
use Carp;
sub function {
   confess "Error in module!";
}
1;

當從類似於以下內容的指令碼中呼叫時 −

use T;
function();

它將產生以下結果 −

Error in module! at T.pm line 9
   T::function() called at test.pl line 4

更新於: 29-11-2019

1K+ 瀏覽量

開啟你的 職業生涯

完成課程獲得認證

開始學習
廣告
© . All rights reserved.