> > $last = index $string, $substring, -1, -1; # last occurence
>
> Err... shouldn't that be
>
> $last = index $string, $substring, 0, -1 # last occurrence
> $first = index $string, $substring, -1, -1 # first occurrence found
> # in a perverse way
>
> Or am I seeing double negatives where I shouldn't?
No. You're missing the fact that the third argument of rindex specifies
the last character at which the match can be found (as opposed to index's
third arg which specifies the *first* character from which to search)
Damian