I tinkered with that too, and then abandoned it simply because it seemed to require too much status checking. If $tail isn't found in $string, index returns a -1, so you've got to check for that. And then if index() - 4 doesn't exist, you have another problem that will generate a warning, so an out of bounds check needs to be performed as well. I suspect that the substr(..., index()) method is at least as speed efficient as the regexp approach, but it's definately more cumbersome to implement.
I still like the substr/index approach for its straightforwardness, but regret the implementation will probably tend to look a little unPerlish.
Dave
In reply to Re^3: substring problem???
by davido
in thread substring problem???
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |