Discussion Locked

Operate on substrings with substr

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
The Feb. 4, Perl TechMail discusses the substr function. Have you used the substr function to operate on strings in your application development?

1 reply

by acroroy

The newsletter mentioned the optional 4th argument in passing, but didn't add any detail.

The 4th arg to substr() is REPLACEMENT. While substr() can be used as an lvalue (substr(...) = $expr;), the replacement can also be passed as the 4th arg, so that substr() can perform a replacement and return a string fragment simultaneously (in other words, act like splice() ).

This discussion is closed to new replies.