额,是。之前我理解错了。
$ cat test.pl
use 5.010;
our $str = "abc";
my $str = "123";
{
my $str = "def";
say ${str};
say ${'str'};
}
say ${str};
say ${'str'};
$ perl test.pl
def
abc
123
abc
一直带着strict和warnings写perl,都不知道还有这么个情况在 2013年1月4日下午10:34,夏凯 <[email protected]>写道: > On 2013年01月04日 19:40, Anthony WU wrote: > >> 因�� ${xxx} 只能�{用 全域��量 >> > 不是啊,${a}就是局部的,${'a'}才是全局的。 > > > -- > 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 > 要取消订阅此网上论坛,请发送电子邮件至 > perlchina+unsubscribe@**googlegroups.com<perlchina%[email protected]> > 。 > 若有更多问题,请通过 > http://groups.google.com/**group/perlchina?hl=zh-CN<http://groups.google.com/group/perlchina?hl=zh-CN>访问此网上论坛。 > > -- 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
