perl好像没有提供strlen函数,用rindex函数可以同样得到字符串的长度。
$str = "abcd 1234";
$len = rindex $str."/$", "/$";
print "$len/n";
执行结果: lenght of 'abcd 1234' is: 9
$str = "abcd 1234";
$len = rindex $str."/$", "/$";
print "$len/n";
执行结果: lenght of 'abcd 1234' is: 9
博客指出Perl未提供strlen函数,可使用rindex函数获取字符串长度。文中给出示例代码,定义字符串“abcd 1234”,通过rindex函数计算其长度,最终输出结果显示该字符串长度为9。
2596

被折叠的 条评论
为什么被折叠?



