my @things = $text =~ /thing/g;
标量上下文中的$thing是字符串$text中子字符串事件的非重叠出现次数.
在Perl 6中如何做到这一点?
my $text = 'thingthingthing' my @things = $text ~~ m:g/thing/; say +@things; # 3
~~左侧与右侧匹配,m:g使测试返回包含所有结果的List [Match].