SilasTheMonk has asked for the wisdom of the Perl Monks concerning the following question:
'I am a mean perlmonk.' => 'i-am-a-mean-perlmonk',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:
'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'
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.$title =~ s{\s}{_}g; $title =~ s{\/}{_}g; $title =~ s{\W}{}g; $title =~ s{_}{-}g; return lc($title);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RFC: Module to take a title and generate the core bit of the URL
by Corion (Patriarch) on Jul 15, 2010 at 10:55 UTC | |
by SilasTheMonk (Chaplain) on Jul 15, 2010 at 11:09 UTC |