Logo

Programming-Idioms

History of Idiom 169 > diff from v42 to v43

Edit summary for version 43 by dmaestro:
New Perl implementation by user [dmaestro]

Version 42

2018-05-21, 23:13:46

Version 43

2018-08-18, 20:04:29

Idiom #169 String length

Assign to integer n the number of characters of string s.

This can be different from the number of bytes of s.

Illustration

Idiom #169 String length

Assign to integer n the number of characters of string s.

This can be different from the number of bytes of s.

Illustration
Extra Keywords
size
Extra Keywords
size
Imports

Code
my $n = length( $s );
Comments bubble
This may break under the 'use bytes' pragma, which is discouraged in modern perls.
Doc URL
https://perldoc.perl.org/perlfunc.html#length-EXPR
Demo URL
https://gist.github.com/dmaestro/42ffe787d290f479c0161abf3e47f6d8