Logo

Programming-Idioms

History of Idiom 38 > diff from v20 to v21

Edit summary for version 21 by :

Version 20

2015-09-05, 15:26:26

Version 21

2015-09-06, 16:15:06

Idiom #38 Extract a substring

Find substring t consisting in characters i (included) to j (excluded) of string s.
(character indexes start at 0 unless specified otherwise)

Idiom #38 Extract a substring

Find substring t consisting in characters i (included) to j (excluded) of string s.
(character indexes start at 0 unless specified otherwise)

Code
my $chunk = substr("now is the time", 3, 4);
Code
my $chunk = substr("now is the time", i, j);
Comments bubble
Get four characters starting at position 3 (the fourth character, since perl is 0-based).
Comments bubble
Perl is 0-based: i=3 would start at the 4th character.