- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

length EXPR


Returns the length in characters of the value of EXPR. If EXPR is omitted, returns length of $_. If EXPR is undefined, returns undef.

This function 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.

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, use length(Encode::encode_utf8(EXPR)) (you'll have to use Encode first). See "->renew" (Encode) in the Perl Unicode and Locales Manual and "Unicode support in Perl" (perlunicode) in the Perl Unicode and Locales Manual.

ISBN 9781906966027Perl Language Reference ManualSee the print edition