Logo

Programming-Idioms

History of Idiom 38 > diff from v29 to v30

Edit summary for version 30 by :
[Perl] Added the documentation url, and add “$” in front of variables, as you would in perl.

Version 29

2016-01-01, 01:55:46

Version 30

2016-01-01, 19:58:01

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", i, j);
Code
my $chunk = substr("now is the time", $i, $j);
Comments bubble
Perl is 0-based: i=3 would start at the 4th character.
Comments bubble
Perl is 0-based: i=3 would start at the 4th character.
Doc URL
http://perldoc.perl.org/functions/substr.html