line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of ModuleUnderscore |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is copyright (c) 2014 by celogeek . |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
package Module::Underscore; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: convert module name to underscore string name and underscore string name to module name |
12
|
2
|
|
|
2
|
|
1551
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
70
|
|
13
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
101
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.4'; # VERSION |
15
|
2
|
|
|
2
|
|
11
|
use base 'Exporter'; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
636
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
18
|
|
|
|
|
|
|
underscore_to_module |
19
|
|
|
|
|
|
|
module_to_underscore |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub underscore_to_module { |
25
|
8
|
|
|
8
|
1
|
4808
|
my ($underscore_string) = @_; |
26
|
8
|
|
|
|
|
19
|
my $module_string = lc($underscore_string); |
27
|
8
|
|
|
|
|
63
|
$module_string =~ s/[^a-z0-9]+(.?)/::\u$1/gx; |
28
|
8
|
|
|
|
|
17
|
$module_string = ucfirst($module_string); |
29
|
|
|
|
|
|
|
|
30
|
8
|
|
|
|
|
41
|
return $module_string; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub module_to_underscore { |
34
|
5
|
|
|
5
|
1
|
2916
|
my ($module_string) = @_; |
35
|
|
|
|
|
|
|
|
36
|
5
|
|
|
|
|
12
|
my $underscore_string = lc($module_string); |
37
|
5
|
|
|
|
|
24
|
$underscore_string =~ s/[^a-z0-9]+/_/gx; |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
28
|
return $underscore_string; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |