line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Slugify; |
2
|
|
|
|
|
|
|
# ABSTRACT: create URL slugs from text |
3
|
|
|
|
|
|
|
$Text::Slugify::VERSION = '0.002'; |
4
|
2
|
|
|
2
|
|
21420
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
69
|
|
5
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
63
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
14
|
use Exporter 'import'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
461
|
|
8
|
|
|
|
|
|
|
our $unaccent = 0; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
if(eval "require Text::Unaccent::PurePerl") { |
11
|
|
|
|
|
|
|
$unaccent = 1; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw(slugify); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub slugify { |
16
|
36
|
|
|
36
|
0
|
14974
|
my ($text) = @_; |
17
|
|
|
|
|
|
|
|
18
|
36
|
50
|
|
|
|
79
|
if($unaccent) { |
19
|
36
|
|
|
|
|
76
|
$text = Text::Unaccent::PurePerl::unac_string($text); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
36
|
|
|
|
|
964
|
$text =~ s/[^a-z0-9]+/-/gi; |
23
|
36
|
|
|
|
|
162
|
$text =~ s/^-?(.+?)-?$/$1/; |
24
|
36
|
|
|
|
|
148
|
$text =~ s/^(.+)$/\L$1/; |
25
|
36
|
|
|
|
|
131
|
return $text; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |