我正在尝试删除导入的符号,以便它们作为对象中的方法不可用,但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 ×1