Perl Programming Documentation
Download Perl
Explore

Manual

- Overview
- Tutorials
- FAQs
- History / Changes
- License

Reference

- Language
- Functions
- Operators
- Special Variables
- Pragmas
- Utilities
- Internals
- Platform Specific

Modules

- A • B • C • D • E
- F • G • H • I • L
- M • N • O • P • S
- T • U • X

Tools

- Preferences

# length

Perl 5 version 18.2 documentation
Go to top
Show recent pages
Recently read

# length

Perl functions A-Z | Perl functions by category | The 'perlfunc' manpage

- length EXPR

- length

  Returns the length in characters of the value of EXPR. If EXPR is omitted, returns the 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 Encode and perlunicode.