line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Facile; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
187554
|
use strict; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
293
|
|
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
37
|
use vars qw($VERSION $TEMPLATE); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
757
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.03'; |
7
|
|
|
|
|
|
|
our $TEMPLATE = 'template'; |
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
37
|
use Carp; |
|
7
|
|
|
|
|
27
|
|
|
7
|
|
|
|
|
17457
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# log template config |
12
|
|
|
|
|
|
|
my @tmpl_accessor = ('TEMPLATE', 'DATE', 'LEVEL', 'MESSAGE',); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# available accessor list |
15
|
|
|
|
|
|
|
my @accessor = ( |
16
|
|
|
|
|
|
|
'log_file', 'level_debug', 'level_info', 'level_error', |
17
|
|
|
|
|
|
|
'level_warn', 'level_fatal', 'swap_dir', 'date_format', |
18
|
|
|
|
|
|
|
'debug_flag', $TEMPLATE, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# constructor |
22
|
|
|
|
|
|
|
sub new |
23
|
|
|
|
|
|
|
{ |
24
|
6
|
|
|
6
|
1
|
4599
|
my ($class, $log_file, $swap_dir) = @_; |
25
|
|
|
|
|
|
|
|
26
|
6
|
|
|
|
|
91
|
bless { |
27
|
|
|
|
|
|
|
log_file => $log_file, |
28
|
|
|
|
|
|
|
swap_dir => $swap_dir, |
29
|
|
|
|
|
|
|
date_format => 'yyyy/mm/dd hh:mi:ss', |
30
|
|
|
|
|
|
|
$TEMPLATE => { |
31
|
|
|
|
|
|
|
'TEMPLATE' => 'DATE [LEVEL] MESSAGE', |
32
|
|
|
|
|
|
|
'DATE' => undef, |
33
|
|
|
|
|
|
|
'LEVEL' => undef, |
34
|
|
|
|
|
|
|
'MESSAGE' => undef, |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
}, $class; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# getter |
40
|
|
|
|
|
|
|
sub get |
41
|
|
|
|
|
|
|
{ |
42
|
498
|
|
|
498
|
1
|
4341
|
my ($self, $key, $tmpl_key) = @_; |
43
|
|
|
|
|
|
|
|
44
|
498
|
100
|
|
|
|
837
|
if (_is_tmpl_accessor($key, $tmpl_key) == 1) |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
# log template value |
47
|
13
|
|
|
|
|
572
|
return $self->{$TEMPLATE}->{$tmpl_key}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
elsif (_is_tmpl_accessor($key, $tmpl_key) == 2) |
50
|
|
|
|
|
|
|
{ |
51
|
|
|
|
|
|
|
# new template value |
52
|
274
|
|
|
|
|
2239
|
return $self->{$TEMPLATE}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
elsif (_is_valid_accessor($key)) |
55
|
|
|
|
|
|
|
{ |
56
|
|
|
|
|
|
|
# get field |
57
|
208
|
|
|
|
|
8373
|
return $self->{$key}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else |
60
|
|
|
|
|
|
|
{ |
61
|
|
|
|
|
|
|
# error |
62
|
0
|
|
|
|
|
0
|
return 0; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# setter |
67
|
|
|
|
|
|
|
sub set |
68
|
|
|
|
|
|
|
{ |
69
|
29
|
|
|
29
|
1
|
2099
|
my ($self, $key, $value_or_key, $tmpl_value) = @_; |
70
|
|
|
|
|
|
|
|
71
|
29
|
100
|
|
|
|
75
|
if (_is_tmpl_accessor($key, $value_or_key) == 1) |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
72
|
|
|
|
|
|
|
{ |
73
|
4
|
|
|
|
|
9
|
$self->{$TEMPLATE}->{$value_or_key} = $tmpl_value; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
elsif (_is_tmpl_accessor($key, $value_or_key) == 2) |
76
|
|
|
|
|
|
|
{ |
77
|
2
|
|
|
|
|
6
|
push @tmpl_accessor, $value_or_key; |
78
|
2
|
|
|
|
|
6
|
$self->{$TEMPLATE}->{$value_or_key} = $tmpl_value; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
elsif (_is_tmpl_accessor($key, $value_or_key) == 255) |
81
|
|
|
|
|
|
|
{ |
82
|
0
|
|
|
|
|
0
|
return 0; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
elsif (_is_valid_accessor($key)) |
85
|
|
|
|
|
|
|
{ |
86
|
20
|
|
|
|
|
63
|
$self->{$key} = $value_or_key; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
else |
89
|
|
|
|
|
|
|
{ |
90
|
0
|
|
|
|
|
0
|
return 0; |
91
|
|
|
|
|
|
|
} |
92
|
26
|
|
|
|
|
111
|
return $self; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# tmpl accessor check |
96
|
|
|
|
|
|
|
sub _is_tmpl_accessor |
97
|
|
|
|
|
|
|
{ |
98
|
1227
|
|
|
1227
|
|
1623
|
my ($tmpl_key, $key) = @_; |
99
|
|
|
|
|
|
|
|
100
|
1227
|
|
|
|
|
1419
|
my $enable = 0; |
101
|
1227
|
100
|
66
|
|
|
5399
|
if (defined $tmpl_key && $tmpl_key eq $TEMPLATE) |
102
|
|
|
|
|
|
|
{ |
103
|
746
|
|
|
|
|
780
|
$enable = 2; |
104
|
746
|
|
|
|
|
871
|
for my $each (@tmpl_accessor) |
105
|
|
|
|
|
|
|
{ |
106
|
2872
|
100
|
100
|
|
|
20779
|
if (defined $key && $each eq $key) |
|
|
100
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
107
|
|
|
|
|
|
|
{ |
108
|
190
|
|
|
|
|
220
|
$enable = 1; |
109
|
190
|
|
|
|
|
263
|
last; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
elsif (defined $key |
112
|
|
|
|
|
|
|
&& ($each =~ m/$key/ || $key =~ m/$each/)) |
113
|
|
|
|
|
|
|
{ |
114
|
4
|
|
|
|
|
446
|
croak "Can't use '" |
115
|
|
|
|
|
|
|
. $key |
116
|
|
|
|
|
|
|
. "' to template " |
117
|
|
|
|
|
|
|
. "because '" |
118
|
|
|
|
|
|
|
. $each |
119
|
|
|
|
|
|
|
. "' has already used."; |
120
|
0
|
|
|
|
|
0
|
$enable = 255; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
1223
|
|
|
|
|
4177
|
return $enable; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# accessor check |
128
|
|
|
|
|
|
|
sub _is_valid_accessor |
129
|
|
|
|
|
|
|
{ |
130
|
230
|
|
|
230
|
|
373
|
my $key = shift; |
131
|
|
|
|
|
|
|
|
132
|
230
|
|
|
|
|
271
|
my $enable = 0; |
133
|
230
|
|
|
|
|
328
|
for my $each (@accessor) |
134
|
|
|
|
|
|
|
{ |
135
|
1366
|
100
|
66
|
|
|
5403
|
if (defined $key && $key eq $each) |
136
|
|
|
|
|
|
|
{ |
137
|
228
|
|
|
|
|
249
|
$enable = 1; |
138
|
228
|
|
|
|
|
300
|
last; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
} |
141
|
230
|
100
|
|
|
|
1356
|
croak 'invalid field name :-P - ' . $key if !$enable; |
142
|
228
|
|
|
|
|
523
|
return $enable; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# replace log item |
146
|
|
|
|
|
|
|
sub _replace_log_item |
147
|
|
|
|
|
|
|
{ |
148
|
173
|
|
|
173
|
|
238
|
my ($self, $key, $value) = @_; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# get defined object |
151
|
173
|
100
|
33
|
|
|
463
|
if ( defined $key |
|
|
100
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
152
|
|
|
|
|
|
|
&& _is_tmpl_accessor($TEMPLATE, $key) == 1 |
153
|
|
|
|
|
|
|
&& defined $self->get($TEMPLATE)->{$key}) |
154
|
|
|
|
|
|
|
{ |
155
|
29
|
|
|
|
|
64
|
return $self->get($TEMPLATE)->{$key}; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
elsif ( defined $key |
158
|
|
|
|
|
|
|
&& $key eq 'DATE' |
159
|
|
|
|
|
|
|
&& !defined $self->get($TEMPLATE)->{'DATE'}) |
160
|
|
|
|
|
|
|
{ |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# get date default sub |
163
|
48
|
|
|
|
|
750
|
return $self->_current_date(); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
else |
166
|
|
|
|
|
|
|
{ |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# return accepted value |
169
|
96
|
|
|
|
|
177
|
return $value; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# get log output string |
174
|
|
|
|
|
|
|
sub _get_log_str |
175
|
|
|
|
|
|
|
{ |
176
|
24
|
|
|
24
|
|
43
|
my ($self, $date, $level, $message) = @_; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# template hash |
179
|
24
|
|
|
|
|
662
|
my $t_hash = $self->get($TEMPLATE); |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
# log template string |
182
|
24
|
|
|
|
|
47
|
my $log_str = $t_hash->{'TEMPLATE'}; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# default values |
185
|
24
|
|
|
|
|
82
|
$log_str =~ s/DATE/$date/g; |
186
|
24
|
|
|
|
|
72
|
$log_str =~ s/LEVEL/$level/g; |
187
|
24
|
|
|
|
|
61
|
$log_str =~ s/MESSAGE/$message/g; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# user defined values |
190
|
24
|
|
|
|
|
41
|
for my $key (@tmpl_accessor) |
191
|
|
|
|
|
|
|
{ |
192
|
101
|
|
|
|
|
206
|
my $replace = $self->_replace_log_item($key); |
193
|
101
|
|
|
|
|
1027
|
$log_str =~ s/$key/$replace/g; |
194
|
|
|
|
|
|
|
} |
195
|
24
|
|
|
|
|
106
|
return $log_str; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# log writer |
199
|
|
|
|
|
|
|
sub _write |
200
|
|
|
|
|
|
|
{ |
201
|
24
|
|
|
24
|
|
53
|
my ($self, $p_level, $p_message) = @_; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
# default values |
204
|
24
|
|
|
|
|
61
|
my $date = $self->_replace_log_item('DATE'); |
205
|
24
|
|
|
|
|
75
|
my $level = $self->_replace_log_item('LEVEL', $p_level); |
206
|
24
|
|
|
|
|
73
|
my $message = $self->_replace_log_item('MESSAGE', $p_message); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
# log string |
209
|
24
|
|
|
|
|
78
|
my $log_str = $self->_get_log_str($date, $level, $message) . $/; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# execute writing log file |
212
|
24
|
50
|
|
|
|
180
|
open my $log, ">> " . $self->get('log_file') |
213
|
|
|
|
|
|
|
or croak 'log file open error - ' . $!; |
214
|
24
|
|
|
|
|
344
|
print $log $log_str; |
215
|
24
|
50
|
|
|
|
1348
|
close $log |
216
|
|
|
|
|
|
|
or croak 'log file close error - ' . $!; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub debug |
220
|
|
|
|
|
|
|
{ |
221
|
6
|
|
|
6
|
1
|
16
|
my ($self, $message_str) = @_; |
222
|
6
|
100
|
|
|
|
22
|
if ($self->get('debug_flag')) |
223
|
|
|
|
|
|
|
{ |
224
|
4
|
100
|
|
|
|
14
|
my $level = |
225
|
|
|
|
|
|
|
defined $self->get('level_debug') |
226
|
|
|
|
|
|
|
? $self->get('level_debug') |
227
|
|
|
|
|
|
|
: 'DEBUG'; |
228
|
4
|
|
|
|
|
28
|
return $self->_write($level, $message_str); |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
else |
231
|
|
|
|
|
|
|
{ |
232
|
2
|
|
|
|
|
9
|
return 1; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
sub info |
237
|
|
|
|
|
|
|
{ |
238
|
8
|
|
|
8
|
1
|
25
|
my ($self, $message_str) = @_; |
239
|
8
|
100
|
|
|
|
30
|
my $level = |
240
|
|
|
|
|
|
|
defined $self->get('level_info') |
241
|
|
|
|
|
|
|
? $self->get('level_info') |
242
|
|
|
|
|
|
|
: 'INFO'; |
243
|
8
|
|
|
|
|
34
|
return $self->_write($level, $message_str); |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
sub error |
247
|
|
|
|
|
|
|
{ |
248
|
4
|
|
|
4
|
1
|
11
|
my ($self, $message_str) = @_; |
249
|
4
|
100
|
|
|
|
11
|
my $level = |
250
|
|
|
|
|
|
|
defined $self->get('level_error') |
251
|
|
|
|
|
|
|
? $self->get('level_error') |
252
|
|
|
|
|
|
|
: 'ERROR'; |
253
|
4
|
|
|
|
|
15
|
return $self->_write($level, $message_str); |
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub warn |
257
|
|
|
|
|
|
|
{ |
258
|
4
|
|
|
4
|
1
|
11
|
my ($self, $message_str) = @_; |
259
|
4
|
100
|
|
|
|
12
|
my $level = |
260
|
|
|
|
|
|
|
defined $self->get('level_warn') |
261
|
|
|
|
|
|
|
? $self->get('level_warn') |
262
|
|
|
|
|
|
|
: 'WARN'; |
263
|
4
|
|
|
|
|
19
|
return $self->_write($level, $message_str); |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub fatal |
267
|
|
|
|
|
|
|
{ |
268
|
4
|
|
|
4
|
1
|
8
|
my ($self, $message_str) = @_; |
269
|
4
|
100
|
|
|
|
11
|
my $level = |
270
|
|
|
|
|
|
|
defined $self->get('level_fatal') |
271
|
|
|
|
|
|
|
? $self->get('level_fatal') |
272
|
|
|
|
|
|
|
: 'FATAL'; |
273
|
4
|
|
|
|
|
12
|
return $self->_write($level, $message_str); |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
sub swap |
277
|
|
|
|
|
|
|
{ |
278
|
6
|
|
|
6
|
1
|
18
|
my ($self, $swap_dir) = @_; |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
# set swap dir |
281
|
6
|
100
|
|
|
|
26
|
if (defined $swap_dir) |
|
|
50
|
|
|
|
|
|
282
|
|
|
|
|
|
|
{ |
283
|
2
|
|
|
|
|
8
|
$self->set('swap_dir', $swap_dir); |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
elsif (!defined $self->get('swap_dir')) |
286
|
|
|
|
|
|
|
{ |
287
|
0
|
|
|
|
|
0
|
my $log_dir = $self->get('log_file'); |
288
|
0
|
|
|
|
|
0
|
$log_dir =~ s/(.+\/).+$/$1/; |
289
|
0
|
|
|
|
|
0
|
$self->set('swap_dir', $log_dir); |
290
|
|
|
|
|
|
|
} |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
# get log filename prefix |
293
|
6
|
|
|
|
|
19
|
my $file_pref = $self->get('log_file'); |
294
|
6
|
|
|
|
|
68
|
$file_pref =~ s/.+\/(.+?)$/$1/; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
# move current log file |
297
|
6
|
100
|
|
|
|
18
|
if (!-d $self->get('swap_dir')) |
298
|
|
|
|
|
|
|
{ |
299
|
1
|
50
|
|
|
|
3
|
mkdir $self->get('swap_dir') |
300
|
|
|
|
|
|
|
or croak 'create swap dir error - ' . $!; |
301
|
|
|
|
|
|
|
} |
302
|
5
|
100
|
|
|
|
18
|
if (-f $self->get('log_file')) |
303
|
|
|
|
|
|
|
{ |
304
|
4
|
50
|
|
|
|
13
|
rename $self->get('log_file'), $self->get('swap_dir') . '/' . $file_pref |
305
|
|
|
|
|
|
|
or croak 'current file move error - ' . $!; |
306
|
|
|
|
|
|
|
} |
307
|
|
|
|
|
|
|
else |
308
|
|
|
|
|
|
|
{ |
309
|
1
|
|
|
|
|
6
|
return 1; |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
# rename files |
313
|
4
|
50
|
|
|
|
42
|
opendir my $s_dir, $self->get('swap_dir') |
314
|
|
|
|
|
|
|
or croak 'dir open error - ' . $!; |
315
|
|
|
|
|
|
|
|
316
|
4
|
|
|
|
|
576
|
for my $each (grep /$file_pref/, reverse sort readdir $s_dir) |
317
|
|
|
|
|
|
|
{ |
318
|
6
|
|
|
|
|
22
|
$each = $self->get('swap_dir') . '/' . $each; |
319
|
6
|
|
|
|
|
17
|
my $rename_pref = $self->get('swap_dir') . '/' . $file_pref . '.'; |
320
|
6
|
100
|
|
|
|
40
|
if ($each =~ /\.(\d)$/) |
321
|
|
|
|
|
|
|
{ |
322
|
2
|
50
|
|
|
|
200
|
rename $each, $rename_pref . ($1 + 1) |
323
|
|
|
|
|
|
|
or croak 'rename error (' . $rename_pref . ($1 + 1) . ') - ' . $!; |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
else |
326
|
|
|
|
|
|
|
{ |
327
|
4
|
50
|
|
|
|
3470
|
rename $each, $rename_pref . '1' |
328
|
|
|
|
|
|
|
or croak 'rename error (' . $rename_pref . '.1) - ' . $!; |
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
} |
331
|
4
|
50
|
|
|
|
149
|
closedir $s_dir |
332
|
|
|
|
|
|
|
or croak 'dir close error - ' . $!; |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
# get current datetime |
336
|
|
|
|
|
|
|
sub _current_date |
337
|
|
|
|
|
|
|
{ |
338
|
48
|
|
|
48
|
|
67
|
my ($self, $pat) = @_; |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
# datetime values |
341
|
48
|
|
|
|
|
1967
|
my @da = localtime(time); |
342
|
48
|
|
|
|
|
230
|
my $year4 = sprintf("%04d", $da[5] + 1900); |
343
|
48
|
|
|
|
|
103
|
my $year2 = sprintf("%02d", $da[5] + 1900 - 2000); |
344
|
48
|
|
|
|
|
127
|
my $month = sprintf("%02d", $da[4] + 1); |
345
|
48
|
|
|
|
|
88
|
my $day = sprintf("%02d", $da[3]); |
346
|
48
|
|
|
|
|
127
|
my $hour = sprintf("%02d", $da[2]); |
347
|
48
|
|
|
|
|
82
|
my $min = sprintf("%02d", $da[1]); |
348
|
48
|
|
|
|
|
626
|
my $sec = sprintf("%02d", $da[0]); |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
# date format |
351
|
48
|
50
|
|
|
|
112
|
my $date_str = |
352
|
|
|
|
|
|
|
(defined $self->get('date_format')) |
353
|
|
|
|
|
|
|
? $self->get('date_format') |
354
|
|
|
|
|
|
|
: 'yyyy/mm/dd hh:mi:ss'; |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
# replace format values |
357
|
48
|
|
|
|
|
206
|
$date_str =~ s/yyyy/$year4/g; |
358
|
48
|
|
|
|
|
75
|
$date_str =~ s/yy/$year2/g; |
359
|
48
|
|
|
|
|
162
|
$date_str =~ s/mm/$month/g; |
360
|
48
|
|
|
|
|
115
|
$date_str =~ s/dd/$day/g; |
361
|
48
|
|
|
|
|
104
|
$date_str =~ s/hh/$hour/g; |
362
|
48
|
|
|
|
|
113
|
$date_str =~ s/mi/$min/g; |
363
|
48
|
|
|
|
|
110
|
$date_str =~ s/ss/$sec/g; |
364
|
|
|
|
|
|
|
|
365
|
48
|
|
|
|
|
166
|
return $date_str; |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
1; |
369
|
|
|
|
|
|
|
__END__ |