Perl version


  • TUX


Perl 5 version 10.0 documentation
Recently read


  • 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 number of characters, not the number of bytes. To get the length of the internal string in bytes, use bytes::length(EXPR) , see bytes. Note that the internal encoding is variable, and the number of bytes usually meaningless. To get the number of bytes that the string would have when encoded as UTF-8, use length(Encoding::encode_utf8(EXPR)).