| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OK::Utils; |
|
2
|
|
|
|
|
|
|
=head1 NAME |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
OK::Utils - Orkun Karaduman's utilities |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 VERSION |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
version 1.01_01 |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Orkun Karaduman's utilities |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 INSTALLATION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
To install this module type the following |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
perl Makefile.PL |
|
19
|
|
|
|
|
|
|
make |
|
20
|
|
|
|
|
|
|
make test |
|
21
|
|
|
|
|
|
|
make install |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
from CPAN |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
cpan -i OK::Utils |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
|
28
|
1
|
|
|
1
|
|
36305
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
80
|
|
|
29
|
1
|
|
|
1
|
|
12
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
95
|
|
|
30
|
1
|
|
|
1
|
|
8
|
no warnings qw(qw utf8); |
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
63
|
|
|
31
|
1
|
|
|
1
|
|
38
|
use v5.14; |
|
|
1
|
|
|
|
|
4
|
|
|
32
|
1
|
|
|
1
|
|
1278
|
use utf8; |
|
|
1
|
|
|
|
|
19
|
|
|
|
1
|
|
|
|
|
8
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
BEGIN |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
1
|
|
|
1
|
|
244
|
require Exporter; |
|
38
|
|
|
|
|
|
|
# set the version for version checking |
|
39
|
1
|
|
|
|
|
6
|
our $VERSION = '1.01_01'; |
|
40
|
|
|
|
|
|
|
# Inherit from Exporter to export functions and variables |
|
41
|
1
|
|
|
|
|
23
|
our @ISA = qw(Exporter); |
|
42
|
|
|
|
|
|
|
# Functions and variables which are exported by default |
|
43
|
1
|
|
|
|
|
3
|
our @EXPORT = qw(); |
|
44
|
|
|
|
|
|
|
# Functions and variables which can be optionally exported |
|
45
|
1
|
|
|
|
|
616
|
our @EXPORT_OK = qw(str_trim str_ltrim str_rtrim file_get_contents); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub str_trim |
|
50
|
|
|
|
|
|
|
{ |
|
51
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
|
52
|
0
|
|
|
|
|
|
$s =~ s/^\s+|\s+$//g; |
|
53
|
0
|
|
|
|
|
|
return $s |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub str_ltrim |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
|
59
|
0
|
|
|
|
|
|
$s =~ s/^\s+//; |
|
60
|
0
|
|
|
|
|
|
return $s |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub str_rtrim |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
|
66
|
0
|
|
|
|
|
|
$s =~ s/\s+$//; |
|
67
|
0
|
|
|
|
|
|
return $s |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub file_get_contents |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
0
|
|
|
0
|
0
|
|
my $file = $_[0]; |
|
73
|
|
|
|
|
|
|
my $document = do |
|
74
|
0
|
|
|
|
|
|
{ |
|
75
|
0
|
|
|
|
|
|
local $/ = undef; |
|
76
|
0
|
0
|
|
|
|
|
open my $fh, "<", $file or return; |
|
77
|
0
|
|
|
|
|
|
my $result = <$fh>; |
|
78
|
0
|
|
|
|
|
|
close $fh; |
|
79
|
0
|
|
|
|
|
|
$result; |
|
80
|
|
|
|
|
|
|
}; |
|
81
|
0
|
|
|
|
|
|
return $document; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
|
86
|
|
|
|
|
|
|
__END__ |