11
我的previous question已经解决了我的问题,但让我缺乏理解。在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'), 'cannot carp');
这个测试没有通过,这意味着no ...
没有做什么,我想这样做,其中包括unimporting的符号。我读过perldoc no
,但它确实看起来很没有说服力。鉴于此代码的结果,我会说它并不完全按照它的广告。
no
是做什么用的?何时以及为什么我应该使用它?
有人可能会争辩说,'出口商'没有定义'unimport'来与其“进口”一起是一个错误。 – geekosaur 2012-04-25 18:40:58
@geekosaur,我同意。 (可以争辩:)) – pilcrow 2012-04-25 18:41:46