duy*_*uye 2 perl with-statement
在这个文件中
https://github.com/csirtgadgets/massive-octo-spice/blob/develop/src/lib/CIF/Observable/Binary.pm ,
我对这句话感到困惑
'CIF :: Observable';
在第9行.在Perl中有关键字'with'吗?这个怎么运作?
package CIF::Observable::Binary;
use strict;
use warnings;
use Mouse;
use Digest::SHA qw/sha256_hex/;
with 'CIF::Observable';
use constant DEFAULT_HASH_TYPE => 'sha256';
has '+otype' => (
default => 'binary',
);
has 'hash' => (
is => 'ro',
isa => 'CIF::Type::Hash',
default => sub { sha256_hex($_[0]->{'observable'}) },
);
has 'htype' => (
is => 'ro',
isa => 'Str',
default => DEFAULT_HASH_TYPE(),
);
sub process {}
sub understands {
my $self = shift;
my $args = shift;
return unless($args->{'observable'});
return unless($args->{'otype'});
return unless($args->{'otype'} eq 'binary');
return 1;
}
__PACKAGE__->meta()->make_immutable();
1;
Run Code Online (Sandbox Code Playgroud)
对象系统with使用该关键字Mouse来指示正在定义的类使用指定的角色
Mouse是Moose对象系统的简化实现,主要是为了减少基于程序所期望的长编译时间Moose
处理角色的方式Mouse几乎与中的相同Moose,Moose::Role文档适用于两个模块