General discussion

Locked

Operate on substrings with substr

By Mark W. Kaelin Editor ·
The Feb. 4, Perl TechMail discusses the substr function. Have you used the substr function to operate on strings in your application development?

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Thr Fourth Element

by AcroRoy In reply to Operate on substrings wit ...

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() ).

Back to Web Development Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums