Perl length 函数

描述

This function returns the length, in characters, of the value of EXPR, or $_ if not specified. Use scalar context on an array or hash if you want to determine the corresponding size.


语法

以下是此函数的简单语法 −

length EXPR

length

返回值

This function returns the size of string.


示例

以下是显示其基本用法的示例代码 −

#!/usr/bin/perl

$orig_string = "This is Test and CAPITAL";
$string_len =  length( orig_string );

print "Length of  String is : $string_len\n";

执行上述代码时,会产生以下结果 −

Length of  String is : 11

❮ Perl 函数参考