Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^2: Chomping most of a _long_ text string

by ihb (Deacon)
on May 29, 2005 at 18:37 UTC ( [id://461553] : note . print w/replies, xml ) Need Help??

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


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