The confess Function in Perl

PERLServer Side ProgrammingProgramming Scripts

The confess function in Perl is like cluck; it calls die and then prints a stack trace all the way up to the origination script.

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

When called from a script like below −

use T;
function();

It will produce the following result −

Error in module! at T.pm line 9
   T::function() called at test.pl line 4
raja
Published on 29-Nov-2019 11:49:28
Advertisements