line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::VisualPrintf; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = "3.11"; |
4
|
|
|
|
|
|
|
|
5
|
13
|
|
|
13
|
|
113804
|
use v5.10; |
|
13
|
|
|
|
|
95
|
|
6
|
13
|
|
|
13
|
|
74
|
use strict; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
315
|
|
7
|
13
|
|
|
13
|
|
68
|
use warnings; |
|
13
|
|
|
|
|
36
|
|
|
13
|
|
|
|
|
339
|
|
8
|
13
|
|
|
13
|
|
68
|
use Carp; |
|
13
|
|
|
|
|
37
|
|
|
13
|
|
|
|
|
1185
|
|
9
|
|
|
|
|
|
|
|
10
|
13
|
|
|
13
|
|
91
|
use Exporter 'import'; |
|
13
|
|
|
|
|
34
|
|
|
13
|
|
|
|
|
868
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(&vprintf &vsprintf); |
12
|
|
|
|
|
|
|
|
13
|
13
|
|
|
13
|
|
6645
|
use Data::Dumper; |
|
13
|
|
|
|
|
65579
|
|
|
13
|
|
|
|
|
781
|
|
14
|
13
|
|
|
13
|
|
11134
|
use Text::VisualPrintf::Transform; |
|
13
|
|
|
|
|
44
|
|
|
13
|
|
|
|
|
1018
|
|
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
1
|
0
|
sub vprintf { &printf (@_) } |
17
|
3
|
|
|
3
|
1
|
151256
|
sub vsprintf { &sprintf(@_) } |
18
|
|
|
|
|
|
|
|
19
|
13
|
|
|
13
|
|
129
|
use Text::VisualWidth::PP; |
|
13
|
|
|
|
|
37
|
|
|
13
|
|
|
|
|
717
|
|
20
|
|
|
|
|
|
|
our $IS_TARGET = qr/[\e\b\P{ASCII}]/; |
21
|
|
|
|
|
|
|
our $VISUAL_WIDTH = \&Text::VisualWidth::PP::width; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub sprintf { |
24
|
593
|
|
|
593
|
1
|
393298
|
my($format, @args) = @_; |
25
|
593
|
|
|
|
|
3071
|
my $xform = Text::VisualPrintf::Transform |
26
|
|
|
|
|
|
|
->new(except => $format, |
27
|
|
|
|
|
|
|
test => $IS_TARGET, |
28
|
|
|
|
|
|
|
length => $VISUAL_WIDTH, |
29
|
|
|
|
|
|
|
max => int @args, |
30
|
|
|
|
|
|
|
); |
31
|
593
|
50
|
|
|
|
2385
|
$xform->encode(@args) if $xform; |
32
|
593
|
|
|
|
|
4202
|
my $s = CORE::sprintf $format, @args; |
33
|
593
|
50
|
|
|
|
3063
|
$xform->decode($s) if $xform; |
34
|
593
|
|
|
|
|
6521
|
$s; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub printf { |
38
|
22
|
50
|
|
22
|
1
|
1089634
|
my $fh = ref($_[0]) =~ /^(?:GLOB|IO::)/ ? shift : select; |
39
|
22
|
|
|
|
|
143
|
$fh->print(&sprintf(@_)); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |