Created
February 27, 2015 22:58
-
-
Save blabos-zz/cba2467ae964373f33bc to your computer and use it in GitHub Desktop.
Perl Slugify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Text::Iconv; | |
my $converter = Text::Iconv->new('utf-8', 'ASCII//TRANSLIT'); | |
my $separator = '-'; | |
my $slug = lc $converter->convert('Coração de Anão'); | |
$slug =~ s/ /_/g; | |
$slug =~ s/\W//g; | |
$slug =~ s/_/$separator/g; | |
print $slug; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment