Perl 中的 carp 函式


Perl 中的 carp 函式是 warn 的基礎等價物,將訊息列印到 STDERR 上,而實際不退出指令碼並列印指令碼名稱。

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

當從如下指令碼中呼叫時 -

use T;
function();

將生成以下結果 -

Error in module! at test.pl line 4

更新日期:2019-11-29

911 次瀏覽

開啟你的 事業

完成課程獲得認證

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