Perl length Function

Advertisements


Description

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.

Syntax

Following is the simple syntax for this function:

length EXPR

length

Return Value

This function returns the size of string.

Example

Following is the example code showing its basic usage:

#!/usr/bin/perl

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

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

When above code is executed, it produced following result

Length of  String is : 11


Advertisements
Advertisements