Logo

Programming-Idioms

History of Idiom 169 > diff from v46 to v47

Edit summary for version 47 by programming-idioms.org:
[Perl] Fixed empty imports

Version 46

2018-09-16, 11:49:10

Version 47

2018-09-23, 19:17:01

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 characters chars number runes
Extra Keywords
size characters chars number runes
Imports

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