Carp::Clan



examples/error/carp_clan.pl
#!/usr/bin/perl
use strict;
use warnings;

use App::Module;

App::Module::f("x");
# Parameter needs to be a number at App/Code.pm line 11.

App::Module::g("x");
# Parameter needs to be a number at App/Module.pm line 15

App::Module::h("x");
# App::Module::h(): Parameter needs to be a number at carp_clan.pl line 11

examples/error/App/Code.pm
package App::Code;
use strict;
use warnings;

use Carp::Clan qw(^App::);
use Carp ();

sub f {
    my ($x) = @_;
 
    warn "Parameter needs to be a number" if $x =~ /\D/;
    return $x;
}

sub g {
    my ($x) = @_;
 
    Carp::carp "Parameter needs to be a number" if $x =~ /\D/;
    return $x;
}

sub h {
    my ($x) = @_;
 
    carp "Parameter needs to be a number" if $x =~ /\D/;
    return $x;
}


1;

examples/error/App/Module.pm
package App::Module;
use strict;
use warnings;

use Carp qw(carp cluck);
use App::Code;

sub f {
    my ($x) = @_;
    App::Code::f($x); 
}

sub g {
    my ($x) = @_;
    App::Code::g($x); 
}

sub h {
    my ($x) = @_;
    App::Code::h($x); 
}


1;