如何限制Perl的分割功能?

joe*_*joe 1 perl split

我试过这个:

$string ="Group: ALL:ALL:Good";

@str2  = split (/:/,':',2);

print "@str2";
Run Code Online (Sandbox Code Playgroud)

我正在寻找$str[0] = Group$str[1]= ALL:ALL:Good.

它不起作用.会有什么问题?

Tho*_*mas 11

你不是这个意思吗?

@str2  = split (/:/,$string,2);
Run Code Online (Sandbox Code Playgroud)

否则,你将分裂字符串:,这似乎没有意义.