我有以下一段代码:(出于这个问题的目的,非常简化,但完美地说明了我遇到的问题)
#!/usr/bin/perl
use strict;
use warnings;
&outer;
my $connected_sub;
sub outer {
print "HELLO\n";
&$connected_sub;
$connected_sub = sub {
print "GOODBYE\n";
}
}
运行程序时会给出以下输出和错误:
HELLO
Use of uninitialized value in subroutine entry at subTesting line 13.
Can't use string ("") as a subroutine ref while "strict refs" in use at subTesting.pl line 13.
我在这里完全忽略了什么吗?我无法理解或弄清楚这是什么问题。