Programming Perl

Programming PerlSearch this book
Previous: 3.2.83 lcfirstChapter 3
Functions
Next: 3.2.85 link
 

3.2.84 length

length EXPR

This function returns the length in bytes of the scalar value EXPR. If EXPR is omitted, the function returns the length of $_, but be careful that the next thing doesn't look like the start of an EXPR, or the tokener will get confused. When in doubt, always put in parentheses.

Do not try to use length to find the size of an array or hash. Use scalar @array for the size of an array, and scalar keys %hash for the size of a hash. (The scalar is typically dropped when redundant, which is typical.)


Previous: 3.2.83 lcfirstProgramming PerlNext: 3.2.85 link
3.2.83 lcfirstBook Index3.2.85 link