I have a need for a good perl module to convert an article title to a nice URL string. For example
'I am a mean perlmonk.' => 'i-am-a-mean-perlmonk',
'RFC: Module to take a title and generate the core bit of the URL' => 'rfc-module-to-take-a-title-and-generate-the-core-bit-of-the-url',
'I have deep-seated emotional problems!' => 'i-have-deep-seated-emotional-problems'
'Sacrificing minions: is there any problem it can't solve?' => 'sacrificing-minions-is-there-any-problem-it-cant-solve'
I find it hard to believe that nothing on CPAN attempt to solve this problem. The following code does a reasonable job on the easy cases:
$title =~ s{\s}{_}g;
$title =~ s{\/}{_}g;
$title =~ s{\W}{}g;
$title =~ s{_}{-}g;
return lc($title);
However it needs to do a lot better. It falls up over entities such as '’'. It needs to know about UTF8 and be able to distinguish between exotic letters and exotic punctuation. In some cases it should give up and throw an exception. Does anyone know a module that already does this. I have tried searching CPAN but found nothing.