如何获取Perl中的字符串的长度?

前端之家收集整理的这篇文章主要介绍了如何获取Perl中的字符串的长度?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
什么是perl等价于strlen()?

解决方法

perldoc -f length

   length EXPR
   length  Returns the length in characters of the value of EXPR.  If EXPR is
           omitted,returns length of $_.  Note that this cannot be used on an
           entire array or hash to find out how many elements these have.  For
           that,use "scalar @array" and "scalar keys %hash" respectively.

           Note the characters: if the EXPR is in Unicode,you will get the num-
           ber of characters,not the number of bytes.  To get the length in
           bytes,use "do { use bytes; length(EXPR) }",see bytes.
原文链接:/Perl/173418.html

猜你在找的Perl相关文章