Returns the length incharacters of the value of EXPR. If EXPR is omitted, returns the length of$_
. If EXPR is undefined, returnsundef
.
This function cannot be used on an entire array or hash to find out how many elements these have. For that, usescalar @array
andscalar keys %hash
, respectively.
Like all Perl character operations,length
normally deals in logical characters, not physical bytes. For how many bytes a string encoded as UTF-8 would take up, uselength(Encode::encode('UTF-8', EXPR))
(you'll have touse Encode
first). SeeEncode andperlunicode.
Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.
The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.