blib/lib/IO/Util.pm

filter: Statementstmt 85.8% 164 / 191 Branchbran 70.6% 65 / 92 Conditioncond 57.5% 23 / 40 MC/DCmcdc 28.0% 7 / 25 Subroutinesub 64.1% 25 / 39 Podpod 70.0% 7 / 10 totaltotal 73.3% 291 / 397 CC 62 SCAR 22.9
CC
62
Cov
78%
load_mml
30.6
parse_mml
14.0
_get_parsing_cache
12.0
CRAP 9.9
↑ Summary
1 package IO::Util ;
2 7 $VERSION = 1.5 ;
3 7 ▶use 5.006_001 ;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use strict ;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # This file uses the "Perlish" coding style
7 # please read http://perl.4pro.net/perlish_coding_style.html
8  
9 ; use Carp
10 7 ▶; $Carp::Internal{+__PACKAGE__}++
Subroutine BEGIN: called CC=1 SCAR=0.0
11 ; use File::Spec
12  
13 ############# slurping files #############
14  
15 7 ▶; sub slurp
Subroutine BEGIN: called CC=1 SCAR=0.0
16 10 ▶ { my %a = map {ref||path => $_} @_
Subroutine slurp: called CC=10 SCAR=23.0
Pod documented
Condition100%2/2
ref $_ || 'path'
l!l
56
MC/DC100%1/1
ref $_ || 'path'
ref $_
Truth table100%2/2
A
A= ref $_
Aresult
11
00
17 ; local $_ = defined $a{path} ? $a{path}
18 : defined $a{GLOB} ? $a{GLOB}
19 10 ▶ : (defined && length) ? $_
Branch: 3 branches
BranchTrueFalseTotal
defined $a{'path'} ? : 6 4 10
defined $a{'GLOB'} ? : 1 3 4
defined $_ && length $_ ? : 2 1 3
Condition66%2/3
defined $_ and length $_
!ll&&!rl&&r
102
MC/DC50%1/2
defined $_ and length $_
defined $_ length $_
Truth table66%2/3
A and B
A= defined $_B= length $_
ABresult
0X0
100
111
20 : croak 'Wrong file argument, died'
21 9 ▶ ; $a{SCALAR} ||= \ my $content
Condition100%2/2
$a{"SCALAR"} ||= \my $content
l!l
36
MC/DC100%1/1
$a{"SCALAR"} ||= \my $content
$a{"SCALAR"}
Truth table100%2/2
A
A= $a{"SCALAR"}
Aresult
11
00
22 9 ▶ ; if ( ref eq 'GLOB'
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ eq 'GLOB' or ref \$_ eq 'GLOB') { } 3 6 9
Condition100%3/3
ref $_ eq "GLOB" or ref \$_ eq "GLOB"
l!l&&r!l&&!r
126
MC/DC100%2/2
ref $_ eq "GLOB" or ref \$_ eq "GLOB"
ref $_ eq "GLOB" ref \$_ eq "GLOB"
Truth table100%3/3
A or B
A= ref $_ eq "GLOB"B= ref \$_ eq "GLOB"
ABresult
1X1
011
000
23 || ref \$_ eq 'GLOB'
24 )
25 3 { ${$a{SCALAR}} = do { local $/; <$_> }
26 }
27 else
28 6 ▶ { open _ or croak "$^E, died"
Branch: 1 branch
BranchTrueFalseTotal
open _ or croak("$^E, died") 5 1 6
29 5 ; ${$a{SCALAR}} = do { local $/; <_> }
30 5 ; close _
31 }
32 ; $a{SCALAR}
33 8 }
34  
35  
36 ############# unique ids #############
37  
38 7 ; my %charset = ( base34 => [ 1..9, 'A'..'N', 'P'..'Z' ]
39 , base62 => [ 0..9, 'a'..'z', 'A'..'Z' ]
40 )
41 7 ; my $separator = '_'
42  
43 ; sub import
44 6 ▶ { return unless @_
Subroutine import: called CC=4 SCAR=13.9
45 6 ▶ ; require Exporter
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 6 6
46 6 ; our @ISA = 'Exporter'
47 6 ; our @EXPORT_OK = qw| capture
48 slurp
49 Tid Lid Uid
50 load_mml
51 |
52 6 ; my ($pkg, @subs) = @_
53 6 ▶ ; require Time::HiRes if grep /id$/ , @subs
Branch: 1 branch
BranchTrueFalseTotal
if grep /id$/, @subs 1 5 6
54 6 ▶ ; require Sys::Hostname if grep /^Uid$/, @subs
Branch: 1 branch
BranchTrueFalseTotal
if grep /^Uid$/, @subs 1 5 6
55 6 ; $pkg->export_to_level(1, @_)
56 }
57
58 ; sub _convert
59 54 ▶ { my ( $num, $args ) = @_
Subroutine _convert: called CC=5 SCAR=16.1
60 ; my $chars = defined $$args{chars}
61 ? ref($$args{chars}) eq 'ARRAY'
62 ? $$args{chars}
63 : exists $charset{$$args{chars}}
64 ? $charset{$$args{chars}}
65 : croak 'Invalid chars, died'
66 : $charset{base34}
67 54 ▶ ; my $result = ''
Branch: 3 branches
BranchTrueFalseTotal
defined $args->{'chars'} ? : 36 18 54
ref $args->{'chars'} eq 'ARRAY' ? : 18 18 36
exists $charset{$args->{'chars'}} ? : 18 0 18
68 54 ; my $dnum = @$chars
69 54 ▶ ; while ( $num > 0 )
Branch: 1 branch
BranchTrueFalseTotal
if ($num > 0) 271 54 325
70 271 { substr($result, 0, 0) = $$chars[ $num % $dnum]
71 271 ; $num = int($num/$dnum)
72 }
73 54 ; $result
74 }
75  
76 ; sub Tid
77 18 ▶ { require Time::HiRes
Subroutine Tid: called CC=4 SCAR=14.6
Pod documented
78 18 ; my %args = @_
79 18 ▶ ; my $sep = defined $args{separator} ? $args{separator} : $separator
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'separator'} ? : 0 18 18
80 18 ; my($sec, $usec) = Time::HiRes::gettimeofday()
81 18 ; my($new_sec, $new_usec)
82 18 ▶ ; do{ ($new_sec, $new_usec) = Time::HiRes::gettimeofday() }
Branch: 1 branch
BranchTrueFalseTotal
($new_usec != $usec or $new_sec != $sec) or do { do { () = &Time::HiRes::gettimeofday() } } 18 0 18
Condition33%1/3
$new_usec != $usec or $new_sec != $sec
l!l&&r!l&&!r
1800
MC/DC0%0/2
$new_usec != $usec or $new_sec != $sec
$new_usec != $usec $new_sec != $sec
Truth table33%1/3
A or B
A= $new_usec != $usecB= $new_sec != $sec
ABresult
1X1
011
000
83 until ( $new_usec != $usec || $new_sec != $sec )
84 18 ; join $sep, map _convert($_, \%args), $sec , $usec
85 }
86
87 ; sub Lid
88 12 ▶ { my %args = @_
Subroutine Lid: called CC=2 SCAR=7.1
Pod documented
89 12 ▶ ; my $sep = defined $args{separator} ? $args{separator} : $separator
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'separator'} ? : 0 12 12
90 12 ; join $sep, _convert($$, \%args), Tid(@_)
91 }
92  
93 ; sub Uid
94 6 ▶ { require Sys::Hostname
Subroutine Uid: called CC=3 SCAR=11.8
Pod documented
95 6 ; my %args = @_
96 6 ▶ ; my $sep = defined $args{separator} ? $args{separator} : $separator
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'separator'} ? : 0 6 6
97 ; my $ip = sprintf '1%03d%03d%03d%03d'
98 , $args{IP}
99 0 ▶ ? @{$args{IP}}
Branch: 1 branch
BranchTrueFalseTotal
$args{'IP'} ? : 0 6 6
100 : unpack( "C4", (gethostbyname(Sys::Hostname::hostname()))[4] )
101 6 ; join $sep, _convert($ip, \%args), Lid(@_)
102 }
103  
104 ############# parsing cache #############
105  
106 7 ; our %PARSING_CACHE
107  
108 ; sub _path_mtime
109 0 ▶ { my $path = File::Spec->rel2abs($_[0])
Subroutine _path_mtime: not called CC=2 SCAR=17.9
110 0 ▶ ; my $mtime = ( stat($path) )[9] or croak "$^E, died"
Branch: 1 branch
BranchTrueFalseTotal
my $mtime = (stat $path)[9] or croak("$^E, died") 0 0 0
111 0 ; $path, $mtime
112 }
113  
114 ; sub _set_parsing_cache
115 0 ▶ { my $type = shift
Subroutine _set_parsing_cache: not called CC=1 SCAR=6.9
116 0 ; my ($path, $mtime) = &_path_mtime
117 0 ; $PARSING_CACHE{$type}{$path}{mtime} = $mtime
118 0 ; $PARSING_CACHE{$type}{$path}{value} = $_[1]
119 }
120
121 ; sub _get_parsing_cache
122 0 ▶ { my $type = shift
Subroutine _get_parsing_cache: not called CC=3 SCAR=24.8
123 0 ; my ($path, $mtime) = &_path_mtime
124 ; exists $PARSING_CACHE{$type}{$path} # if it is cached
125 &&! $mtime > $PARSING_CACHE{$type}{$path}{mtime} # and not old
126 ? $PARSING_CACHE{$type}{$path}{value}
127 : undef
128 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
exists $IO::Util::PARSING_CACHE{$type}{$path} && !$mtime > $IO::Util::PARSING_CACHE{$type}{$path}{'mtime'} ? : 0 0 0
Condition0%0/3
exists $IO::Util::PARSING_CACHE{$type}{$path} and !$mtime > $IO::Util::PARSING_CACHE{$type}{$path}{"mtime"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $IO::Util::PARSING_CACHE{$type}{$path} and !$mtime > $IO::Util::PARSING_CACHE{$type}{$path}{"mtime"}
exists $IO::Util::PARSING_CACHE{$type}{$path} !$mtime > $IO::Util::PARSING_CACHE{$type}{$path}{"mtime"}
Truth table0%0/3
A and not(B)
A= exists $IO::Util::PARSING_CACHE{$type}{$path}B= !$mtime > $IO::Util::PARSING_CACHE{$type}{$path}{"mtime"}
ABresult
0X0
100
111
129  
130 ; sub _purge_parsing_cache
131 0 ▶ { my $type = shift
Subroutine _purge_parsing_cache: not called CC=2 SCAR=17.9
132 0 ▶ ; @_ || return delete $PARSING_CACHE{$type}
Branch: 1 branch
BranchTrueFalseTotal
@_ or return delete $IO::Util::PARSING_CACHE{$type} 0 0 0
133 0 ; map delete $PARSING_CACHE{$type}{$_}
134 , map File::Spec->rel2abs($_)
135 , @_
136 }
137  
138 ############# loading MML #############
139  
140  
141 7 ; my %parser_re = ( '<>' =>
142 qr/ \G(.*?) # elements and text outside blocks
143 (?<!\\)< # not excaped '<'
144 (\w+)([^>]*?) # id + attributes
145 (?<!\\)> # not escaped '>'
146 (.*?) # content
147 <\/\2> # end
148 /xs
149 , '[]' =>
150 qr/ \G(.*?) # elements and text outside blocks
151 (?<!\\)\[ # not excaped '['
152 (\w+)([^\]]*?) # id + attributes
153 (?<!\\)\] # not escaped ']'
154 (.*?) # content
155 \[\/\2\] # end
156 /xs
157 , '{}' =>
158 qr/ \G(.*?) # elements and text outside blocks
159 (?<!\\)\{ # not excaped '<'
160 (\w+)([^\}]*?) # id + attributes
161 (?<!\\)\} # not escaped '>'
162 (.*?) # content
163 \{\/\2\} # end
164 /xs
165 )
166
167 7 ; my %not_escaped_re = ( '<>' => qr/( (?<!\\) < | (?<!\\) > )/xs
168 , '[]' => qr/( (?<!\\) \[ | (?<!\\) \] )/xs
169 , '{}' => qr/( (?<!\\) \{ | (?<!\\) \} )/xs
170 )
171
172 7 ; my %comment_re = ( '<>' => qr/<!--.*?-->/xs
173 , '[]' => qr/\[!--.*?--\]/xs
174 , '{}' => qr/\{!--.*?--\}/xs
175 )
176
177 ; sub load_mml
178 40 ▶ { my $mml = shift
Subroutine load_mml: called CC=16 SCAR=34.2
Pod documented
179 40 ▶ ; my $opt = ref $_[0] eq 'HASH' ? $_[0] : { @_ }
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 40 40
180 40 ▶ ; if ( $$opt{optional} && not ref $mml )
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{"optional"} and not ref $mml) 0 40 40
Condition33%1/3
$opt->{"optional"} and not ref $mml
!ll&&!rl&&r
4000
MC/DC0%0/2
$opt->{"optional"} and not ref $mml
$opt->{"optional"} not ref $mml
Truth table33%1/3
A and not(B)
A= $opt->{"optional"}B= not ref $mml
ABresult
0X0
100
111
181 0 ▶ { return unless -f $mml
Branch: 1 branch
BranchTrueFalseTotal
unless -f $mml 0 0 0
182 }
183 40 ; my $struct
184 40 ▶ ; defined $$opt{cache} or $$opt{cache} = 1
Branch: 1 branch
BranchTrueFalseTotal
defined $opt->{"cache"} or $opt->{"cache"} = 1 0 40 40
185 40 ▶ ; if ( $$opt{cache} && not ref $mml )
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{"cache"} and not ref $mml) 0 40 40
Condition33%1/3
$opt->{"cache"} and not ref $mml
!ll&&!rl&&r
0400
MC/DC0%0/2
$opt->{"cache"} and not ref $mml
$opt->{"cache"} not ref $mml
Truth table33%1/3
A and not(B)
A= $opt->{"cache"}B= not ref $mml
ABresult
0X0
100
111
186 0 { $struct = _get_parsing_cache 'mml_struct', $mml
187 0 ▶ ; return $struct if $struct
Branch: 1 branch
BranchTrueFalseTotal
if $struct 0 0 0
188 }
189 40 ▶ ; defined $$opt{strict} or $$opt{strict} = 1
Branch: 1 branch
BranchTrueFalseTotal
defined $opt->{"strict"} or $opt->{"strict"} = 1 4 36 40
190 40 ▶ ; my $content = ref $mml eq 'SCALAR' ? $mml : slurp $mml
Branch: 1 branch
BranchTrueFalseTotal
ref $mml eq 'SCALAR' ? : 40 0 40
191 40 ▶ ; $$opt{markers} ||= '<>'
Condition100%2/2
$opt->{"markers"} ||= "<>"
l!l
2020
MC/DC100%1/1
$opt->{"markers"} ||= "<>"
$opt->{"markers"}
Truth table100%2/2
A
A= $opt->{"markers"}
Aresult
11
00
192 40 ; $$content =~ s/$comment_re{$$opt{markers}}//g
193 34 ; $struct = parse_mml( '', $content, $opt )
194 34 ▶ ; unless ( $$opt{keep_root} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt->{"keep_root"}) 32 2 34
195 32 ▶ { ref $struct eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
ref $struct eq "HASH" or croak("Parsed structure is not a HASH reference: check your MML or set keep_root, died") 32 0 32
196 or croak 'Parsed structure is not a HASH reference: '
197 . 'check your MML or set keep_root, died'
198 32 ; $struct = $$struct{(keys %$struct)[0]}
199 }
200 34 ▶ ; $$opt{cache} &&! ref($mml)
Branch: 1 branch
BranchTrueFalseTotal
$opt->{"cache"} and not ref $mml and _set_parsing_cache("mml_struct", $mml, $struct) 0 34 34
Condition33%1/3
$opt->{"cache"} and not ref $mml
!ll&&!rl&&r
0340
MC/DC0%0/2
$opt->{"cache"} and not ref $mml
$opt->{"cache"} not ref $mml
Truth table33%1/3
A and not(B)
A= $opt->{"cache"}B= not ref $mml
ABresult
0X0
100
111
201 && _set_parsing_cache 'mml_struct', $mml, $struct
202 34 ; $struct
203 }
204
205 ; sub parse_mml
206 236 ▶ { my ($id, $mml, $opt) = @_
Subroutine parse_mml: called CC=14 SCAR=26.4
Pod documented
207 236 ; my ($node, $control, $no_data)
208 236 ▶ ; while ( $$mml =~ /$parser_re{$$opt{markers}}/g )
Branch: 1 branch
BranchTrueFalseTotal
if ($$mml =~ /$parser_re{$opt->{"markers"}}/g) 204 236 440
209 204 { $no_data = 1
210 204 ; my ( $garb, $child_id, $attr, $child_mml ) = ($1, $2, $3, $4)
211 204 ▶ ; if ( $$opt{strict} )
Branch: 1 branch
BranchTrueFalseTotal
if ($opt->{"strict"}) 168 36 204
212 168 ▶ { $garb =~ /\S/ && croak
Branch: 1 branch
BranchTrueFalseTotal
$garb =~ /\S/ and croak("Garbage '${garb}' found parsing element '${child_id}', died") 0 168 168
213 "Garbage '$garb' found parsing element '$child_id', died"
214 168 ▶ ; length $attr && croak
Branch: 1 branch
BranchTrueFalseTotal
length $attr and croak("Attributes '${attr}' found parsing element '${child_id}', died") 0 168 168
215 "Attributes '$attr' found parsing element '$child_id', died"
216 }
217 ; my ($k) = grep $child_id =~ /$_/
218 204 , keys %{$$opt{handler}}
219 ; my $parser_sub = defined $k
220 204 ▶ ? $$opt{handler}{$k}
Branch: 1 branch
BranchTrueFalseTotal
defined $k ? : 12 192 204
221 : \&parse_mml
222 7 ▶ ; my $child = do{ no strict 'refs'
Subroutine BEGIN: called CC=1 SCAR=0.0
223 7 ; &$parser_sub($child_id, \$child_mml, $opt)
224 }
225 204 ▶ ; if ( defined $child )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $child) 202 2 204
226 202 ▶ { if ( defined $$control{$child_id} )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $control->{$child_id}) { } 20 182 202
227 20 ▶ { if ( $$control{$child_id} > 1 )
Branch: 1 branch
BranchTrueFalseTotal
if ($control->{$child_id} > 1) { } 8 12 20
228 8 { push @{$$node{$child_id}}, $child
229 }
230 else
231 12 { $$node{$child_id} = [ $$node{$child_id}, $child ]
232 }
233 }
234 else
235 182 { $$node{$child_id} = $child
236 }
237 202 ; $$control{$child_id} ++
238 }
239 }
240 236 ▶ ; return $node if $no_data
Branch: 1 branch
BranchTrueFalseTotal
if $no_data 94 142 236
241 ; $$opt{strict} && ( $$mml =~ $not_escaped_re{$$opt{markers}} )
242 142 ▶ and croak "Not escaped '$1' found in '$id' data, died"
Branch: 1 branch
BranchTrueFalseTotal
$opt->{"strict"} and $$mml =~ /$not_escaped_re{$opt->{"markers"}}/ and croak("Not escaped '$1' found in '${id}' data, died") 0 142 142
Condition66%2/3
$opt->{"strict"} and $$mml =~ /$not_escaped_re{$opt->{"markers"}}/
!ll&&!rl&&r
281140
MC/DC0%0/2
$opt->{"strict"} and $$mml =~ /$not_escaped_re{$opt->{"markers"}}/
$opt->{"strict"} $$mml =~ /$not_escaped_re{$opt->{"markers"}}/
Truth table66%2/3
A and B
A= $opt->{"strict"}B= $$mml =~ /$not_escaped_re{$opt->{"markers"}}/
ABresult
0X0
100
111
243 142 ; $$mml =~ s/\\(.)/$1/g # unescape
244 ; my ($k) = grep $id =~ /$_/
245 142 , keys %{$$opt{filter}}
246 142 ▶ ; my $filter_sub = $$opt{filter}{$k} if defined $k
Branch: 1 branch
BranchTrueFalseTotal
if defined $k 46 96 142
247 ; $filter_sub
248 142 ▶ ? do{ local $_ = $$mml
Branch: 1 branch
BranchTrueFalseTotal
$filter_sub ? : 46 96 142
249 7 ▶ ; no strict 'refs'
Subroutine BEGIN: called CC=1 SCAR=0.0
250 7 ; &{$filter_sub}($id, $mml, $opt)
251 }
252 : $$mml
253 }
254  
255 ; sub TRIM_BLANKS # filter
256 32 ▶ { s/^\s+//gm
Subroutine TRIM_BLANKS: called CC=1 SCAR=0.0
Pod undocumented
257 32 ; s/\s+$//gm
258 32 ; $_
259 }
260  
261 ; sub ONE_LINE # filter
262 30 ▶ { s/\n+/ /g
Subroutine ONE_LINE: called CC=1 SCAR=0.0
Pod undocumented
263 30 ; $_
264 }
265  
266 ; sub SPLIT_LINES # handler
267 2 ▶ { [ split /\n+/, parse_mml @_ ]
Subroutine SPLIT_LINES: called CC=1 SCAR=0.0
Pod undocumented
268 }
269  
270 ############## capturing output #############
271  
272 ; sub capture (&;@)
273 9 ▶ { my %a = map {ref, $_} @_
Subroutine capture: called CC=4 SCAR=13.9
Pod documented
274 9 ▶ ; $a{GLOB} ||= select
Condition66%2/3
$a{"GLOB"} ||= select
l!l&&r!l&&!r
360
MC/DC0%0/2
$a{"GLOB"} ||= select
$a{"GLOB"} select
Truth table66%2/3
A ||= B
A= $a{"GLOB"}B= select
ABresult
1X1
011
000
275 ; local $IO::Util::WriteHandle::out_ref
276 9 ▶ = $a{SCALAR} || \ my $scalar
Condition100%2/2
$a{'SCALAR'} || \my $scalar
l!l
27
MC/DC100%1/1
$a{'SCALAR'} || \my $scalar
$a{'SCALAR'}
Truth table100%2/2
A
A= $a{'SCALAR'}
Aresult
11
00
277 7 ▶ ; no strict 'refs'
Subroutine BEGIN: called CC=1 SCAR=0.0
278 7 ▶ ; if ( my $tied = tied *{$a{GLOB}} )
Branch: 1 branch
BranchTrueFalseTotal
if (my $tied = tied *{$a{'GLOB'};}) { } 2 7 9
279 2 { my $tied_class = ref $tied
280 2 ; bless $tied, 'IO::Util::WriteHandle'
281 2 ; $a{CODE}->()
282 2 ; bless $tied, $tied_class
283 }
284 else
285 7 { tie *{$a{GLOB}}, 'IO::Util::WriteHandle'
286 7 ; $a{CODE}->()
287 7 ; untie *{$a{GLOB}}
288 }
289 9 ; $IO::Util::WriteHandle::out_ref
290 }
291  
292  
293 ###############################
294 ; package IO::Util::WriteHandle
295 ; use strict
296 7 ▶; our $out_ref
Subroutine BEGIN: called CC=1 SCAR=0.0
297  
298 ; sub TIEHANDLE
299 7 ▶ { bless \ my $dummy, $_[0]
Subroutine TIEHANDLE: called CC=1 SCAR=0.0
300 }
301  
302 ; sub WRITE
303 2 ▶ { shift
Subroutine WRITE: called CC=3 SCAR=11.8
304 2 ; my( $scalar, $len, $offset ) = @_
305 2 ▶ ; my $data = substr $scalar
Condition40%2/5
$offset || 0
l!l
02
$len || length $scalar
l!l&&r!l&&!r
200
MC/DC0%0/1
$offset || 0
$offset
MC/DC0%0/2
$len || length $scalar
$len length $scalar
Truth table50%1/2
A
A= $offset
Aresult
11
00
Truth table33%1/3
A || B
A= $lenB= length $scalar
ABresult
1X1
011
000
306 , $offset || 0
307 , $len || length $scalar
308 2 ; $$out_ref .= $data
309 2 ; length $data
310 }
311  
312 ; sub PRINT
313 13 ▶ { shift
Subroutine PRINT: called CC=3 SCAR=11.0
314 13 ▶ ; $$out_ref .= join defined $, ? $, : '', @_
Branch: 1 branch
BranchTrueFalseTotal
defined $, ? : 2 11 13
315 13 ▶ ; $$out_ref .= $\ if defined $\
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 2 11 13
316 13 ; 1
317 }
318  
319 ; sub PRINTF
320 1 ▶ { shift
Subroutine PRINTF: called CC=1 SCAR=0.0
321 1 ; $$out_ref .= sprintf shift, @_
322 1 ; 1
323 }
324  
325 0 ▶; sub OPEN { 1 }
Subroutine OPEN: not called CC=1 SCAR=6.9
326 0 ▶; sub CLOSE { 1 }
Subroutine CLOSE: not called CC=1 SCAR=6.9
327 0 ▶; sub FILENO { 1 }
Subroutine FILENO: not called CC=1 SCAR=6.9
328 0 ▶; sub BINMODE { 1 }
Subroutine BINMODE: not called CC=1 SCAR=6.9
329 7 ▶; sub UNTIE { 1 }
Subroutine UNTIE: called CC=1 SCAR=0.0
330  
331 ###### not supported #######
332 0 ▶; sub READ { 0 }
Subroutine READ: not called CC=1 SCAR=6.9
333 0 ▶; sub READLINE { undef }
Subroutine READLINE: not called CC=1 SCAR=6.9
334 0 ▶; sub GETC { undef }
Subroutine GETC: not called CC=1 SCAR=6.9
335 0 ▶; sub TELL {-1 }
Subroutine TELL: not called CC=1 SCAR=6.9
336 0 ▶; sub SEEK { 0 }
Subroutine SEEK: not called CC=1 SCAR=6.9
337 0 ▶; sub EOF { 1 }
Subroutine EOF: not called CC=1 SCAR=6.9
338  
339  
340 7 ; 1
341 __END__
↑ Summary