关于下面的代码,$ one_sub和$ two_sub如何变成指定子“sup”中的匿名子例程的coderef?指定的子不是'返回'这两个匿名子;还是它? (至少我没有提出这样的声明)。perl命名子程序中的匿名子程序
sub sup {
my $neh = sub {
say "this is 'neh' subroutine"
};
my $hen = sub {
say "this is 'hen' subroutine"
};
($neh, $hen);
}
my ($one_sub, $two_sub) = ⊃
使用数据::自卸车::流光显示的:
$CODE1 = sub {
use warnings;
use strict;
no feature;
use feature ':5.10';
say q[this is 'neh' subroutine];
};
$CODE1 = sub {
use warnings;
use strict;
no feature;
use feature ':5.10';
say q[this is 'hen' subroutine];
};
['-f的perldoc return'(http://perldoc.perl.org/functions/return.html):“在没有一个显式的'return',一个子例程,'eval'或'do FILE'会自动返回最后一个表达式的值。 – ThisSuitIsBlackNot
@ThisSuitIsBlackNot应该可能是一个答案。 –
这是明确回报是好事的原因之一:) – Sobrique