且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Perl 中将字符串拆分为两个字符的块?

更新时间:2022-11-14 16:12:10

@array = ( $string =~ m/../g );

模式匹配运算符在 Perl 的列表上下文中以一种特殊的方式运行.它迭代地处理操作,将模式与前一次匹配之后的文本的其余部分进行匹配.然后列表由在模式匹配的每个应用期间匹配的所有文本形成.

The pattern-matching operator behaves in a special way in a list context in Perl. It processes the operation iteratively, matching the pattern against the remainder of the text after the previous match. Then the list is formed from all the text that matched during each application of the pattern-matching.