相关疑难解决方法(0)

如何在perl中取消导入函数?

我正在尝试删除导入的符号,以便它们作为对象中的方法不可用,但no似乎不起作用,也许我不理解否,或者还有另一种方法.

use 5.014;
use warnings;
use Test::More;

# still has carp after no carp
package Test0 {
    use Carp qw( carp );
    sub new {
        my $class = shift;
        my $self  = {};

        carp 'good';

        bless $self, $class;
        return $self;
    }
    no Carp;
}

my $t0 = Test0->new;

ok( ! $t0->can('carp'), 'can not carp');

# below passes correctly
package Test1 {
    use Carp qw( carp );
    use namespace::autoclean;

    sub new {
        my $class = shift;
        my $self  = …
Run Code Online (Sandbox Code Playgroud)

perl

6
推荐指数
2
解决办法
683
查看次数

标签 统计

perl ×1