당신은 사용할 수 있습니다 Moose::MethodModifiers
. 나는 Moose
에 관해 많이 알지 못하지만 설명서에서 볼 수 있습니다. 여기에 간다.
#!/usr/bin/perl -w
use 5.010;
use strict;
use Moose;
sub sub_one {
say "I am sub one!";
}
sub sub_two {
say "Guess who!";
}
# Note that the name of the function being modified isn't passed in in
# any way
for my $func qw(sub_one sub_two) {
around $func => sub {
my $orig = shift;
say "Running ${func}(@_)";
# call the original sub
my $self = shift;
$self->$orig(@_);
}
}
sub_one(21, 12);
sub_two();
이 내가 그래서 코드에 대한주의 만 초보자 해요 유의하시기 바랍니다
[email protected]:~$ perl method_modifiers.pl
Running sub_one(21 12)
I am sub one!
Running sub_two()
Guess who!
같은 것을 생산하고 있습니다.
감사합니다. –