伙计们,我有点困惑,当我遇到这个时,我正在使用 Perl 进行范围界定:
#! usr/bin/perl
use warnings;
use strict;
sub nested {
our $x = "nested!";
}
print $x; # Error "Variable "$x" is not imported at nested line 10."
print our $x; # Doesn't print "nested!"
print our($x) # Doesn't print "nested!"
但是当我这样做时:
{
our $x = "nested";
}
print our($x); # Prints "nested"
print our $x; # Prints "nested"
print $x; # Prints "nested"
所以你们能向我解释为什么这些有效而不是无效吗?