while( $obj->thing =~ m[subthing]g ) { last if substr( $obj->thing, pos( $obj->thing ) - 22, 22 ) eq 'This is *the* subthing'; }