的各种形式split实际上是:
split MATCHOP,EXPR,LIMITsplit PATTERN,EXPR,LIMITsplit MATCHOP,EXPRsplit PATTERN,EXPRsplit MATCHOPsplit PATTERNsplit在哪里
MATCHOP 是匹配运算符(通常不会执行),并且 PATTERN 是一个返回以下值之一的表达式:
所有这十个在功能上都是等效的:
$re = qr/\s+/;
$pat = '(?^u:\\s+)';
split /\s+/ Match operator
split m/\s+/ Match operator
split m!\s+! Match operator
split qr/\s+/ Expression that returns a compiled regex pattern.
split qr!\s+! Expression that returns a compiled regex pattern.
split $re Expression that returns a compiled regex pattern.
split '(?^u:\s+)' Expression that returns a stringified regex pattern.
split '(?^u:\\s+)' Expression that returns a stringified regex pattern.
split "(?^u:\\s+)" Expression that returns a stringified regex pattern.
split $pat Expression that returns a stringified regex pattern.
Run Code Online (Sandbox Code Playgroud)