Perl extension to rewrite strings based on a set of known prefixes.