http://www.perlmonks.org?node_id=461553


in reply to Re: Chomping most of a _long_ text string
in thread Chomping most of a _long_ text string

I pondered whether I prefered index() or $+[0] and I concluded $+[0]. The index() expression becomes so cluttered, and it has a problem if the substring isn't found. Then you'll destroy the beginning of the string anyway, and remove $u-1 chars from the beginning. I figured that most likely, if the marker isn't there, it's already removed. If not you still need to perform some check, and for me the regex version is nicer.

I'd like to flip the coin and say "matching works find here, no need to use index()", but if one likes index() one should use index(). :-)

ihb

See perltoc if you don't know which perldoc to read!