line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::VisualPrintf; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = "4.01"; |
4
|
|
|
|
|
|
|
|
5
|
13
|
|
|
13
|
|
93231
|
use v5.14; |
|
13
|
|
|
|
|
81
|
|
6
|
13
|
|
|
13
|
|
60
|
use warnings; |
|
13
|
|
|
|
|
21
|
|
|
13
|
|
|
|
|
308
|
|
7
|
13
|
|
|
13
|
|
52
|
use Carp; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
874
|
|
8
|
|
|
|
|
|
|
|
9
|
13
|
|
|
13
|
|
70
|
use Exporter 'import'; |
|
13
|
|
|
|
|
17
|
|
|
13
|
|
|
|
|
726
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw(&vprintf &vsprintf); |
11
|
|
|
|
|
|
|
|
12
|
13
|
|
|
13
|
|
5388
|
use Data::Dumper; |
|
13
|
|
|
|
|
55156
|
|
|
13
|
|
|
|
|
777
|
|
13
|
13
|
|
|
13
|
|
5456
|
use Text::Conceal; |
|
13
|
|
|
|
|
367510
|
|
|
13
|
|
|
|
|
874
|
|
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
1
|
0
|
sub vprintf { &printf (@_) } |
16
|
3
|
|
|
3
|
1
|
122929
|
sub vsprintf { &sprintf(@_) } |
17
|
|
|
|
|
|
|
|
18
|
13
|
|
|
13
|
|
99
|
use Text::VisualWidth::PP; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
587
|
|
19
|
|
|
|
|
|
|
our $IS_TARGET = qr/[\e\b\P{ASCII}]/; |
20
|
|
|
|
|
|
|
our $VISUAL_WIDTH = \&Text::VisualWidth::PP::width; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub sprintf { |
23
|
593
|
|
|
593
|
1
|
318260
|
my($format, @args) = @_; |
24
|
593
|
|
|
|
|
2367
|
my $conceal = Text::Conceal->new( |
25
|
|
|
|
|
|
|
except => $format, |
26
|
|
|
|
|
|
|
test => $IS_TARGET, |
27
|
|
|
|
|
|
|
length => $VISUAL_WIDTH, |
28
|
|
|
|
|
|
|
max => int @args, |
29
|
|
|
|
|
|
|
); |
30
|
593
|
50
|
|
|
|
25065
|
$conceal->encode(@args) if $conceal; |
31
|
593
|
|
|
|
|
641070
|
my $s = CORE::sprintf $format, @args; |
32
|
593
|
50
|
|
|
|
2686
|
$conceal->decode($s) if $conceal; |
33
|
593
|
|
|
|
|
29495
|
$s; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub printf { |
37
|
22
|
50
|
|
22
|
1
|
678156
|
my $fh = ref($_[0]) =~ /^(?:GLOB|IO::)/ ? shift : select; |
38
|
22
|
|
|
|
|
89
|
$fh->print(&sprintf(@_)); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |