$pos = rindex("abcdefghijiklmdef", "def");
print "Found position of def $pos\n";
# Use the first position found as the offset to the
# next search.
# Note that the length of the target string is
# subtracted from the offset to save time.
$pos = rindex("abcdefghijiklmdef", "def", $pos-3 );
print "Found position of def $pos\n";