| 1 | package Langertha::Holmgang::Shell::Filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: The text filters behind a pipe — grep, head, tail, wc, sort, uniq, cut, awk, tr, fold | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 84 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 84 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 84 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 84 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 84 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # cut -d X -f N[,M|N-M] | cut -c N-M | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | sub _cut { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cut: called CC=19 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | my ( $lines, @a ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cut: not called CC=19 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my ( $d, $f, $c ) = ("\t"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if ( $x =~ /\A-d(.+)\z/s ) { $d = $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | elsif ( $x eq '-d' ) { $d = shift @a } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | elsif ( $x =~ /\A-f(.+)\z/ ) { $f = $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | elsif ( $x eq '-f' ) { $f = shift @a } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | elsif ( $x =~ /\A-c(.+)\z/ ) { $c = $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | elsif ( $x eq '-c' ) { $c = shift @a } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my $spec = $f // $c // return ( 'cut: you must specify a list of bytes, characters, or fields', 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition30%3/10
($f // $c) // (return "cut: you must specify a list of bytes, characters, or fields", 0)
$f // $c
($f // $c) // (return "cut: you must specify a list of bytes, characters, or fields", 0)
$f // $c
MC/DC0%0/2
($f // $c) // (return "cut: you must specify a list of bytes, characters, or fields", 0)
$f
$c
MC/DC0%0/2
($f // $c) // (return "cut: you must specify a list of bytes, characters, or fields", 0)
$f
$c
Truth table66%2/3
A // B
A= $fB= $c
Truth table0%0/3
A // B
A= $fB= $c
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my @want; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | for my $p ( split /,/, $spec ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | my ( $from, $to ) = $p =~ /\A(\d*)(?:-(\d*))?\z/ or return ( "cut: invalid field value '$p'", 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $from = 1 if $from eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | push @want, [ $from, defined $2 ? ( $to eq '' ? 1e9 : $to ) : $from ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | for my $l (@$lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ( defined $c ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | push @out, join '', map { substr( $l, $_->[0] - 1, $_->[1] - $_->[0] + 1 ) } @want; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ( index( $l, $d ) < 0 ) { push @out, $l; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my @fld = split /\Q$d\E/, $l, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | push @out, join $d, map { my $w = $_; grep { defined } @fld[ ( $w->[0] - 1 ) .. ( $w->[1] > @fld ? $#fld : $w->[1] - 1 ) ] } @want; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return ( join( "\n", @out ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # awk: die gaengigen Einzeiler — [-F sep] '[BEGIN {…}] [muster] { anweisungen } [END {…}]' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # mit Rechnen (+ - * / %), Variablen und Feldern (Arrays a[k]), Zuweisungen (= += -= *= /= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # %= ++ --), if/else, for (k in a), print/printf, length, int, substr, tolower, toupper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # was darueber hinausgeht (andere Funktionen, Umleitungen, getline), ist eine Luecke (undef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # statt einer stillen Leerstelle. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 51 | ▶ | sub _awk { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_awk: called CC=42 SCAR=45.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | my ( $lines, @a ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_awk: not called CC=42 SCAR=45.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my ( $sep, $prog, %var, %arr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if ( $x =~ /\A-F(.+)\z/s ) { $sep = $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | elsif ( $x eq '-F' ) { $sep = shift @a } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | elsif ( $x eq '-v' ) { my ( $k, $v ) = ( shift(@a) // '' ) =~ /\A(\w+)=(.*)\z/s or return (undef); $var{$k} = $v } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition25%1/4
shift @a // ""
shift @a // ""
MC/DC0%0/1
shift @a // ""
shift @a
MC/DC0%0/1
shift @a // ""
shift @a
Truth table50%1/2
A
A= shift @a
Truth table0%0/2
A
A= shift @a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | elsif ( !defined $prog ) { $prog = $x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | return ( 'usage: awk [-F fs][-v var=value][prog | -f progfile][file ...]', 0 ) unless defined $prog; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $ofs = ' '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # Tokens: Zahlen, Texte, /re/, $, Namen, Operatoren, { } ( ) ; , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my @t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $s = $prog; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $prev = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | while ( length $s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ( $s =~ s/\A\s+// ) { next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | elsif ( $s =~ s/\A"((?:[^"\\]|\\.)*)"// ) { ( my $v = $1 ) =~ s/\\n/\n/g; $v =~ s/\\t/\t/g; $v =~ s/\\(.)/$1/g; push @t, [ 'str', $v ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | elsif ( $prev !~ /\A(?:num|str|name|\)|field)\z/ && $s =~ s{\A/((?:[^/\\]|\\.)*)/}{} ) { push @t, [ 're', $1 ] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
not $prev =~ /\A(?:num|str|name|\)|field)\z/ and $s =~ s(\A/((?:[^/\\]|\\.)*)/)[]
not $prev =~ /\A(?:num|str|name|\)|field)\z/ and $s =~ s(\A/((?:[^/\\]|\\.)*)/)[]
MC/DC100%2/2
not $prev =~ /\A(?:num|str|name|\)|field)\z/ and $s =~ s(\A/((?:[^/\\]|\\.)*)/)[]
not $prev =~ /\A(?:num|str|name|\)|field)\z/
$s =~ s(\A/((?:[^/\\]|\\.)*)/)[]
MC/DC0%0/2
not $prev =~ /\A(?:num|str|name|\)|field)\z/ and $s =~ s(\A/((?:[^/\\]|\\.)*)/)[]
not $prev =~ /\A(?:num|str|name|\)|field)\z/
$s =~ s(\A/((?:[^/\\]|\\.)*)/)[]
Truth table100%3/3
not(A) and B
A= not $prev =~ /\A(?:num|str|name|\)|field)\z/B= $s =~ s(\A/((?:[^/\\]|\\.)*)/)[]
Truth table0%0/3
not(A) and B
A= not $prev =~ /\A(?:num|str|name|\)|field)\z/B= $s =~ s(\A/((?:[^/\\]|\\.)*)/)[]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | elsif ( $s =~ s/\A(\d+(?:\.\d+)?)// ) { push @t, [ 'num', $1 ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | elsif ( $s =~ s/\A([A-Za-z_]\w*)// ) { push @t, [ 'name', $1 ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | elsif ( $s =~ s/\A(\+\+|--|\+=|-=|\*=|\/=|%=|==|!=|<=|>=|!~|&&|\|\||[<>~!\$(){};,=+*\/%\[\]-])// ) { push @t, [ 'op', $1 ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | else { return (undef) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $prev = $t[-1][0] eq 'op' ? $t[-1][1] : $t[-1][0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | $prev = 'field' if $t[-1][0] eq 'num' && @t > 1 && $t[-2][0] eq 'op' && $t[-2][1] eq '$'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition44%8/18
$t[-1][0] eq "num" and @t > 1 and $t[-2][0] eq "op" and $t[-2][1] eq "\$"
$t[-1][0] eq "num" and @t > 1 and $t[-2][0] eq "op"
$t[-1][0] eq "num" and @t > 1
$t[-1][0] eq "num" and @t > 1 and $t[-2][0] eq "op" and $t[-2][1] eq "\$"
$t[-1][0] eq "num" and @t > 1 and $t[-2][0] eq "op"
$t[-1][0] eq "num" and @t > 1
MC/DC75%3/4
$t[-1][0] eq "num" and @t > 1 and $t[-2][0] eq "op" and $t[-2][1] eq "\$"
$t[-1][0] eq "num"
@t > 1
$t[-2][0] eq "op"
$t[-2][1] eq "\$"
MC/DC0%0/4
$t[-1][0] eq "num" and @t > 1 and $t[-2][0] eq "op" and $t[-2][1] eq "\$"
$t[-1][0] eq "num"
@t > 1
$t[-2][0] eq "op"
$t[-2][1] eq "\$"
Truth table80%4/5
A and B and C and D
A= $t[-1][0] eq "num"B= @t > 1C= $t[-2][0] eq "op"D= $t[-2][1] eq "\$"
Truth table0%0/5
A and B and C and D
A= $t[-1][0] eq "num"B= @t > 1C= $t[-2][0] eq "op"D= $t[-2][1] eq "\$"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | my $peek = sub { my $k = $t[$i]; $k && ( @_ ? $k->[0] eq 'op' && $k->[1] eq $_[0] : 1 ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.1
Branch: 2 branches
Condition100%3/3
$k->[0] eq "op" and $k->[1] eq $_[0]
MC/DC100%2/2
$k->[0] eq "op" and $k->[1] eq $_[0]
$k->[0] eq "op"
$k->[1] eq $_[0]
Truth table100%3/3
A and B
A= $k->[0] eq "op"B= $k->[1] eq $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | my $take = sub { die "awk\n" unless $peek->(@_); $t[ $i++ ] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my ( $or, $cmp, $prim, $concat, $sum ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # Zahlwert wie awk (fuehrende Zahl, sonst 0) und Ausgabe einer Rechnung (OFMT %.6g) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | my $num = sub { ( $_[0] // '' ) =~ /\A\s*([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/ ? $1 + 0 : 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
Branch: 1 branch
Condition50%1/2
$_[0] // ""
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | my $fmt = sub { my ($v) = @_; $v == int($v) && abs($v) < 1e16 ? sprintf( '%d', $v ) : sprintf( '%.6g', $v ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
Branch: 1 branch
Condition66%2/3
$v == int $v and abs $v < "1e+16"
MC/DC50%1/2
$v == int $v and abs $v < "1e+16"
$v == int $v
abs $v < "1e+16"
Truth table66%2/3
A and B
A= $v == int $vB= abs $v < "1e+16"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # Werte: Zahl oder Text wie awk (strnum: Felder, die wie Zahlen aussehen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 178 | ▶ | $prim = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=45 SCAR=44.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 178 | ▶ | my $k = $t[$i] or die "awk\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 178 | ▶ | if ( $k->[0] eq 'op' && $k->[1] eq '(' ) { $i++; my $e = $or->(); $take->(')'); return $e } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$k->[0] eq "op" and $k->[1] eq "("
MC/DC100%2/2
$k->[0] eq "op" and $k->[1] eq "("
$k->[0] eq "op"
$k->[1] eq "("
Truth table100%3/3
A and B
A= $k->[0] eq "op"B= $k->[1] eq "("
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 175 | ▶ | if ( $k->[0] eq 'op' && $k->[1] eq '!' ) { $i++; my $e = $prim->(); return sub { $e->(@_) ? 0 : 1 } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 2 branches
Condition100%3/3
$k->[0] eq "op" and $k->[1] eq "!"
MC/DC100%2/2
$k->[0] eq "op" and $k->[1] eq "!"
$k->[0] eq "op"
$k->[1] eq "!"
Truth table100%3/3
A and B
A= $k->[0] eq "op"B= $k->[1] eq "!"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ( $k->[0] eq 'op' && $k->[1] eq '-' ) { $i++; my $e = $prim->(); return sub { $fmt->( -$num->( $e->(@_) ) ) } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Branch: 1 branch
Condition66%2/3
$k->[0] eq "op" and $k->[1] eq "-"
MC/DC0%0/2
$k->[0] eq "op" and $k->[1] eq "-"
$k->[0] eq "op"
$k->[1] eq "-"
Truth table66%2/3
A and B
A= $k->[0] eq "op"B= $k->[1] eq "-"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 174 | ▶ | if ( $k->[0] eq 'op' && $k->[1] eq '$' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$k->[0] eq "op" and $k->[1] eq "\$"
MC/DC50%1/2
$k->[0] eq "op" and $k->[1] eq "\$"
$k->[0] eq "op"
$k->[1] eq "\$"
Truth table66%2/3
A and B
A= $k->[0] eq "op"B= $k->[1] eq "\$"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 56 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 56 | ▶ | my $n = $t[$i] or die "awk\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 56 | ▶ | if ( $n->[0] eq 'num' ) { $i++; my $f = $n->[1]; return sub { $f == 0 ? $_[0] : $_[1][ $f - 1 ] // '' } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
Branch: 2 branches
Condition50%1/2
$_[1][$f - 1] // ""
MC/DC0%0/1
$_[1][$f - 1] // ""
$_[1][$f - 1]
Truth table50%1/2
A
A= $_[1][$f - 1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | if ( $n->[0] eq 'name' && $n->[1] eq 'NF' ) { $i++; return sub { $_[1][-1] // '' } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.8
Branch: 1 branch
Condition40%2/5
$n->[0] eq "name" and $n->[1] eq "NF"
$_[1][-1] // ""
MC/DC0%0/2
$n->[0] eq "name" and $n->[1] eq "NF"
$n->[0] eq "name"
$n->[1] eq "NF"
MC/DC0%0/1
$_[1][-1] // ""
$_[1][-1]
Truth table33%1/3
A and B
A= $n->[0] eq "name"B= $n->[1] eq "NF"
Truth table50%1/2
A
A= $_[1][-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ( $n->[0] eq 'op' && $n->[1] eq '(' ) { my $e = $prim->(); return sub { my $f = int $num->( $e->(@_) ); $f == 0 ? $_[0] : $f < 0 ? '' : $_[1][ $f - 1 ] // '' } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
Branch: 3 branches
Condition0%0/5
$n->[0] eq "op" and $n->[1] eq "("
$_[1][$f - 1] // ""
MC/DC0%0/2
$n->[0] eq "op" and $n->[1] eq "("
$n->[0] eq "op"
$n->[1] eq "("
MC/DC0%0/1
$_[1][$f - 1] // ""
$_[1][$f - 1]
Truth table0%0/3
A and B
A= $n->[0] eq "op"B= $n->[1] eq "("
Truth table0%0/2
A
A= $_[1][$f - 1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | die "awk\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 118 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 118 | ▶ | return sub { $k->[1] } if $k->[0] eq 'num' || $k->[0] eq 'str'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition100%3/3
$k->[0] eq "num" or $k->[0] eq "str"
MC/DC100%2/2
$k->[0] eq "num" or $k->[0] eq "str"
$k->[0] eq "num"
$k->[0] eq "str"
Truth table100%3/3
A or B
A= $k->[0] eq "num"B= $k->[0] eq "str"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 44 | ▶ | if ( $k->[0] eq 're' ) { my $re = eval { qr/$k->[1]/ } // die "awk\n"; return sub { $_[0] =~ $re ? 1 : 0 } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 2 branches
Condition50%1/2
eval {
do {
qr/$k->[1]/
}
} // die("awk\n")
MC/DC0%0/1
eval {
do {
qr/$k->[1]/
}
} // die("awk\n")
eval {
do {
qr/$k->[1]/
}
}
Truth table50%1/2
A
A= eval {
do {
qr/$k->[1]/
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 41 | ▶ | if ( $k->[0] eq 'name' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 41 | my $n = $k->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 41 | ▶ | return sub { $_[2] } if $n eq 'NR' || $n eq 'FNR'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition66%2/3
$n eq "NR" or $n eq "FNR"
MC/DC50%1/2
$n eq "NR" or $n eq "FNR"
$n eq "NR"
$n eq "FNR"
Truth table66%2/3
A or B
A= $n eq "NR"B= $n eq "FNR"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 28 | ▶ | return sub { scalar @{ $_[1] } } if $n eq 'NF'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 27 | ▶ | if ( $n eq 'length' ) { # length, length(), length(ausdruck), length(array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 6 | ▶ | return sub { length $_[0] } unless $peek->('('); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 5 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 5 | ▶ | if ( $peek->(')') ) { $i++; return sub { length $_[0] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | ▶ | my $an = $t[$i][0] eq 'name' && $t[ $i + 1 ] && $t[ $i + 1 ][1] eq ')' ? $t[$i][1] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$t[$i][0] eq "name" and $t[$i + 1] and $t[$i + 1][1] eq ")"
$t[$i][0] eq "name" and $t[$i + 1]
MC/DC0%0/3
$t[$i][0] eq "name" and $t[$i + 1] and $t[$i + 1][1] eq ")"
$t[$i][0] eq "name"
$t[$i + 1]
$t[$i + 1][1] eq ")"
Truth table25%1/4
A and B and C
A= $t[$i][0] eq "name"B= $t[$i + 1]C= $t[$i + 1][1] eq ")"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 4 | my $e = $or->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 4 | $take->(')'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | return sub { defined $an && $arr{$an} ? scalar keys %{ $arr{$an} } : length $e->(@_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=14.2
Branch: 1 branch
Condition33%1/3
defined $an and $arr{$an}
MC/DC0%0/2
defined $an and $arr{$an}
defined $an
$arr{$an}
Truth table33%1/3
A and B
A= defined $anB= $arr{$an}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 21 | ▶ | if ( $n =~ /\A(?:int|tolower|toupper|substr)\z/ && $peek->('(') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$n =~ /\A(?:int|tolower|toupper|substr)\z/ and &$peek("(")
MC/DC50%1/2
$n =~ /\A(?:int|tolower|toupper|substr)\z/ and &$peek("(")
$n =~ /\A(?:int|tolower|toupper|substr)\z/
&$peek("(")
Truth table66%2/3
A and B
A= $n =~ /\A(?:int|tolower|toupper|substr)\z/B= &$peek("(")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 3 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | my @p = ( $or->() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 3 | ▶ | while ( $peek->(',') ) { $i++; push @p, $or->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | $take->(')'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | ▶ | return sub { int $num->( $p[0]->(@_) ) } if $n eq 'int' && @p == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition66%2/3
$n eq "int" and @p == 1
MC/DC50%1/2
$n eq "int" and @p == 1
$n eq "int"
@p == 1
Truth table66%2/3
A and B
A= $n eq "int"B= @p == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | return sub { lc $p[0]->(@_) } if $n eq 'tolower' && @p == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.7
Branch: 1 branch
Condition33%1/3
$n eq "tolower" and @p == 1
MC/DC0%0/2
$n eq "tolower" and @p == 1
$n eq "tolower"
@p == 1
Truth table33%1/3
A and B
A= $n eq "tolower"B= @p == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | ▶ | return sub { uc $p[0]->(@_) } if $n eq 'toupper' && @p == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition66%2/3
$n eq "toupper" and @p == 1
MC/DC50%1/2
$n eq "toupper" and @p == 1
$n eq "toupper"
@p == 1
Truth table66%2/3
A and B
A= $n eq "toupper"B= @p == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | if ( $n eq 'substr' && ( @p == 2 || @p == 3 ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$n eq "substr" and @p == 2 || @p == 3
@p == 2 or @p == 3
MC/DC0%0/3
$n eq "substr" and @p == 2 || @p == 3
$n eq "substr"
@p == 2
@p == 3
Truth table25%1/4
A and B or C
A= $n eq "substr"B= @p == 2C= @p == 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | ▶ | my ( $str, $m ) = ( $p[0]->(@_) // '', int( $num->( $p[1]->(@_) ) + 0.5 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$p[0]->(@_) // ""
MC/DC0%0/1
$p[0]->(@_) // ""
$p[0]->(@_)
Truth table50%1/2
A
A= $p[0]->(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | ▶ | my $len = @p == 3 ? int( $num->( $p[2]->(@_) ) + 0.5 ) : length($str) + 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 4 | ▶ | my ( $from, $to ) = ( $m < 1 ? 1 : $m, $m + $len - 1 ); # wie POSIX awk: 1-basiert, gekappt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 | ▶ | $to = length $str if $to > length $str; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | ▶ | return $to < $from ? '' : substr( $str, $from - 1, $to - $from + 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | die "awk\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 18 | ▶ | die "awk\n" if $peek->('(') || $n =~ /\A(?:getline|in|if|else|for|while|do|next|exit|function|return|delete|BEGIN|END)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
&$peek("(") or $n =~ /\A(?:getline|in|if|else|for|while|do|next|exit|function|return|delete|BEGIN|END)\z/
MC/DC50%1/2
&$peek("(") or $n =~ /\A(?:getline|in|if|else|for|while|do|next|exit|function|return|delete|BEGIN|END)\z/
&$peek("(")
$n =~ /\A(?:getline|in|if|else|for|while|do|next|exit|function|return|delete|BEGIN|END)\z/
Truth table66%2/3
A or B
A= &$peek("(")B= $n =~ /\A(?:getline|in|if|else|for|while|do|next|exit|function|return|delete|BEGIN|END)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 16 | ▶ | if ( $peek->('[') ) { # Array-Element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | my $ke = $or->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | $take->(']'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | return sub { my $key = $ke->(@_); ( $arr{$n} || {} )->{$key} // '' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
Condition50%2/4
+($arr{$n} || {})->{$key} // ""
$arr{$n} || {}
MC/DC0%0/1
+($arr{$n} || {})->{$key} // ""
$arr{$n}
Truth table50%1/2
A
A= $arr{$n}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 14 | ▶ | return sub { $var{$n} // '' }; # nicht gesetzt: "" bzw. 0 wie awk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$var{$n} // ""
MC/DC100%1/1
$var{$n} // ""
$var{$n}
Truth table100%2/2
A
A= $var{$n}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | die "awk\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | my $isnum = sub { defined $_[0] && $_[0] =~ /\A\s*[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?\s*\z/ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # Rechnen: * / % vor + - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 159 | ▶ | my $prod = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 159 | my $l = $prim->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 157 | ▶ | while ( my $k = $t[$i] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 174 | ▶ | last unless $k->[0] eq 'op' && $k->[1] =~ m{\A[*/%]\z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$k->[0] eq "op" and $k->[1] =~ m[\A[*/%]\z]
MC/DC100%2/2
$k->[0] eq "op" and $k->[1] =~ m[\A[*/%]\z]
$k->[0] eq "op"
$k->[1] =~ m[\A[*/%]\z]
Truth table100%3/3
A and B
A= $k->[0] eq "op"B= $k->[1] =~ m[\A[*/%]\z]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 18 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 18 | my ( $op, $a, $b ) = ( $k->[1], $l, $prim->() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 27 | ▶ | $l = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 27 | my ( $x, $y ) = ( $num->( $a->(@_) ), $num->( $b->(@_) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 27 | ▶ | die "awk: cmd. line:1: fatal: division by zero attempted\n" if $op ne '*' && $y == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op ne "*" and $y == 0
MC/DC100%2/2
$op ne "*" and $y == 0
$op ne "*"
$y == 0
Truth table100%3/3
A and B
A= $op ne "*"B= $y == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 26 | ▶ | $fmt->( $op eq '*' ? $x * $y : $op eq '/' ? $x / $y : $x - $y * int( $x / $y ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 18 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 157 | return $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 154 | ▶ | $sum = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 154 | my $l = $prod->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 152 | ▶ | while ( my $k = $t[$i] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 156 | ▶ | last unless $k->[0] eq 'op' && $k->[1] =~ /\A[+-]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$k->[0] eq "op" and $k->[1] =~ /\A[+-]\z/
MC/DC100%2/2
$k->[0] eq "op" and $k->[1] =~ /\A[+-]\z/
$k->[0] eq "op"
$k->[1] =~ /\A[+-]\z/
Truth table100%3/3
A and B
A= $k->[0] eq "op"B= $k->[1] =~ /\A[+-]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 5 | my ( $op, $a, $b ) = ( $k->[1], $l, $prod->() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 5 | ▶ | $l = sub { my ( $x, $y ) = ( $num->( $a->(@_) ), $num->( $b->(@_) ) ); $fmt->( $op eq '+' ? $x + $y : $x - $y ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 152 | return $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 146 | ▶ | $concat = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 146 | my @e = ( $sum->() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 144 | ▶ | while ( my $k = $t[$i] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 151 | ▶ | last if $k->[0] eq 'op' && $k->[1] !~ /\A[\$(]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$k->[0] eq "op" and not $k->[1] =~ /\A[\$(]\z/
MC/DC100%2/2
$k->[0] eq "op" and not $k->[1] =~ /\A[\$(]\z/
$k->[0] eq "op"
not $k->[1] =~ /\A[\$(]\z/
Truth table100%3/3
A and not(B)
A= $k->[0] eq "op"B= not $k->[1] =~ /\A[\$(]\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 10 | ▶ | last if $k->[0] eq 'name' && $k->[1] =~ /\A(?:print|printf|in|if|else|for|while)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$k->[0] eq "name" and $k->[1] =~ /\A(?:print|printf|in|if|else|for|while)\z/
MC/DC100%2/2
$k->[0] eq "name" and $k->[1] =~ /\A(?:print|printf|in|if|else|for|while)\z/
$k->[0] eq "name"
$k->[1] =~ /\A(?:print|printf|in|if|else|for|while)\z/
Truth table100%3/3
A and B
A= $k->[0] eq "name"B= $k->[1] =~ /\A(?:print|printf|in|if|else|for|while)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 8 | ▶ | last if $k->[0] eq 'op' && $k->[1] =~ /\A(?:\+\+|--|\+=|-=|\*=|\/=|%=|=|\])\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$k->[0] eq "op" and $k->[1] =~ m(\A(?:\+\+|--|\+=|-=|\*=|/=|%=|=|\])\z)
MC/DC0%0/2
$k->[0] eq "op" and $k->[1] =~ m(\A(?:\+\+|--|\+=|-=|\*=|/=|%=|=|\])\z)
$k->[0] eq "op"
$k->[1] =~ m(\A(?:\+\+|--|\+=|-=|\*=|/=|%=|=|\])\z)
Truth table66%2/3
A and B
A= $k->[0] eq "op"B= $k->[1] =~ m(\A(?:\+\+|--|\+=|-=|\*=|/=|%=|=|\])\z)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 8 | push @e, $sum->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 144 | ▶ | return $e[0] if @e == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 6 | ▶ | return sub { my @x = @_; join '', map { $_->(@x) } @e }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 57 | ▶ | $cmp = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=13 SCAR=27.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 57 | my $l = $concat->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 57 | ▶ | if ( $t[$i] && $t[$i][0] eq 'name' && $t[$i][1] eq 'in' ) { # (schluessel in array) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$t[$i] and $t[$i][0] eq "name" and $t[$i][1] eq "in"
$t[$i] and $t[$i][0] eq "name"
MC/DC33%1/3
$t[$i] and $t[$i][0] eq "name" and $t[$i][1] eq "in"
$t[$i]
$t[$i][0] eq "name"
$t[$i][1] eq "in"
Truth table50%2/4
A and B and C
A= $t[$i]B= $t[$i][0] eq "name"C= $t[$i][1] eq "in"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | ▶ | my $an = ( $t[ $i++ ] // die "awk\n" )->[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$t[$i++] // die("awk\n")
MC/DC0%0/1
$t[$i++] // die("awk\n")
$t[$i++]
Truth table50%1/2
A
A= $t[$i++]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | ▶ | return sub { exists( ( $arr{$an} || {} )->{ $l->(@_) } ) ? 1 : 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
Condition100%2/2
$arr{$an} || {}
MC/DC100%1/1
$arr{$an} || {}
$arr{$an}
Truth table100%2/2
A
A= $arr{$an}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 55 | my $k = $t[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 55 | ▶ | return $l unless $k && $k->[0] eq 'op' && $k->[1] =~ /\A(?:==|!=|<=|>=|<|>|~|!~)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$k and $k->[0] eq "op" and $k->[1] =~ /\A(?:==|!=|<=|>=|<|>|~|!~)\z/
$k and $k->[0] eq "op"
MC/DC33%1/3
$k and $k->[0] eq "op" and $k->[1] =~ /\A(?:==|!=|<=|>=|<|>|~|!~)\z/
$k
$k->[0] eq "op"
$k->[1] =~ /\A(?:==|!=|<=|>=|<|>|~|!~)\z/
Truth table50%2/4
A and B and C
A= $kB= $k->[0] eq "op"C= $k->[1] =~ /\A(?:==|!=|<=|>=|<|>|~|!~)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 21 | my $op = $k->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 21 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 21 | ▶ | if ( $op eq '~' || $op eq '!~' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "~" or $op eq "!~"
MC/DC100%2/2
$op eq "~" or $op eq "!~"
$op eq "~"
$op eq "!~"
Truth table100%3/3
A or B
A= $op eq "~"B= $op eq "!~"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | my $r = $t[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | my $re; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 3 | ▶ | if ( $r && $r->[0] eq 're' ) { $i++; $re = eval { qr/$r->[1]/ } // die "awk\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$r and $r->[0] eq "re"
eval {
do {
qr/$r->[1]/
}
} // die("awk\n")
MC/DC0%0/2
$r and $r->[0] eq "re"
$r
$r->[0] eq "re"
MC/DC0%0/1
eval {
do {
qr/$r->[1]/
}
} // die("awk\n")
eval {
do {
qr/$r->[1]/
}
}
Truth table33%1/3
A and B
A= $rB= $r->[0] eq "re"
Truth table50%1/2
A
A= eval {
do {
qr/$r->[1]/
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | else { my $e = $concat->(); return sub { my $m = $l->(@_) =~ /${\ $e->(@_)}/ ? 1 : 0; $op eq '~' ? $m : 1 - $m } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 3 | ▶ | return sub { my $m = $l->(@_) =~ $re ? 1 : 0; $op eq '~' ? $m : 1 - $m }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 18 | my $rt = $concat->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 68 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 68 | my ( $x, $y ) = ( $l->(@_), $rt->(@_) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 68 | ▶ | my $c = $isnum->($x) && $isnum->($y) ? ( $x <=> $y ) : ( "$x" cmp "$y" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
&$isnum($x) and &$isnum($y)
MC/DC50%1/2
&$isnum($x) and &$isnum($y)
&$isnum($x)
&$isnum($y)
Truth table66%2/3
A and B
A= &$isnum($x)B= &$isnum($y)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 68 | ▶ | ( $op eq '==' ? $c == 0 : $op eq '!=' ? $c != 0 : $op eq '<' ? $c < 0 : $op eq '<=' ? $c <= 0 : $op eq '>' ? $c > 0 : $c >= 0 ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 18 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 53 | ▶ | my $and = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 53 | my @e = ( $cmp->() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 53 | ▶ | while ( $peek->('&&') ) { $i++; push @e, $cmp->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 53 | ▶ | return @e == 1 ? $e[0] : sub { for my $f (@e) { return 0 unless $f->(@_) } 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 51 | ▶ | $or = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 51 | my @e = ( $and->() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 51 | ▶ | while ( $peek->('||') ) { $i++; push @e, $and->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 51 | ▶ | return @e == 1 ? $e[0] : sub { for my $f (@e) { return 1 if $f->(@_) } 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Anweisungen: print/printf, Zuweisungen (auch a[k], ++/--), if/else, for (k in a), { … }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # jede Anweisung ist ein Code, der ihre Ausgabe (Text) liefert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 25 | ▶ | my $setv = sub { # Wert setzen: Variable (FS/OFS wirken), Array-Element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 25 | my ( $n, $key, $v ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 25 | ▶ | if ( defined $key ) { $arr{$n}{$key} = $v; return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 19 | $var{$n} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 19 | ▶ | $sep = $v if $n eq 'FS'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 19 | ▶ | $ofs = $v if $n eq 'OFS'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my ( $stmt, $block ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 62 | ▶ | $block = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 62 | my @st; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 62 | ▶ | while ( $t[$i] && !$peek->('}') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$t[$i] and not &$peek("}")
MC/DC50%1/2
$t[$i] and not &$peek("}")
$t[$i]
not &$peek("}")
Truth table66%2/3
A and not(B)
A= $t[$i]B= not &$peek("}")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 68 | ▶ | if ( $peek->(';') ) { $i++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 65 | push @st, $stmt->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 57 | ▶ | return sub { my @x = @_; join '', map { $_->(@x) } @st }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 70 | ▶ | $stmt = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=50 SCAR=44.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 70 | ▶ | my $k = $t[$i] or die "awk\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if ( $peek->('{') ) { $i++; my $b = $block->(); $take->('}'); return $b } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 70 | ▶ | if ( $k->[0] eq 'name' && $k->[1] eq 'if' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$k->[0] eq "name" and $k->[1] eq "if"
MC/DC50%1/2
$k->[0] eq "name" and $k->[1] eq "if"
$k->[0] eq "name"
$k->[1] eq "if"
Truth table66%2/3
A and B
A= $k->[0] eq "name"B= $k->[1] eq "if"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | $take->('('); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | my $c = $or->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | $take->(')'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | ▶ | $i++ while $peek->(';'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | my $then = $stmt->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | my $save = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | ▶ | $i++ while $peek->(';'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 2 | my $else; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 2 | ▶ | if ( $t[$i] && $t[$i][0] eq 'name' && $t[$i][1] eq 'else' ) { $i++; $else = $stmt->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$t[$i] and $t[$i][0] eq "name" and $t[$i][1] eq "else"
$t[$i] and $t[$i][0] eq "name"
MC/DC33%1/3
$t[$i] and $t[$i][0] eq "name" and $t[$i][1] eq "else"
$t[$i]
$t[$i][0] eq "name"
$t[$i][1] eq "else"
Truth table50%2/4
A and B and C
A= $t[$i]B= $t[$i][0] eq "name"C= $t[$i][1] eq "else"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | else { $i = $save } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | ▶ | return sub { $c->(@_) ? $then->(@_) : $else ? $else->(@_) : '' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 68 | ▶ | if ( $k->[0] eq 'name' && $k->[1] eq 'for' && $t[ $i + 1 ] && $t[ $i + 1 ][1] eq '(' && $t[ $i + 3 ] && $t[ $i + 3 ][1] eq 'in' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%10/15
$k->[0] eq "name" and $k->[1] eq "for" and $t[$i + 1] and $t[$i + 1][1] eq "(" and $t[$i + 3] and $t[$i + 3][1] eq "in"
$k->[0] eq "name" and $k->[1] eq "for" and $t[$i + 1] and $t[$i + 1][1] eq "(" and $t[$i + 3]
$k->[0] eq "name" and $k->[1] eq "for" and $t[$i + 1] and $t[$i + 1][1] eq "("
$k->[0] eq "name" and $k->[1] eq "for" and $t[$i + 1]
$k->[0] eq "name" and $k->[1] eq "for"
MC/DC16%1/6
$k->[0] eq "name" and $k->[1] eq "for" and $t[$i + 1] and $t[$i + 1][1] eq "(" and $t[$i + 3] and $t[$i + 3][1] eq "in"
$k->[0] eq "name"
$k->[1] eq "for"
$t[$i + 1]
$t[$i + 1][1] eq "("
$t[$i + 3]
$t[$i + 3][1] eq "in"
Truth table28%2/7
A and B and C and D and E and F
A= $k->[0] eq "name"B= $k->[1] eq "for"C= $t[$i + 1]D= $t[$i + 1][1] eq "("E= $t[$i + 3]F= $t[$i + 3][1] eq "in"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | $i += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | my $kv = $t[ $i++ ][1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | ▶ | my $an = ( $t[ $i++ ] // die "awk\n" )->[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$t[$i++] // die("awk\n")
MC/DC0%0/1
$t[$i++] // die("awk\n")
$t[$i++]
Truth table50%1/2
A
A= $t[$i++]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | $take->(')'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 2 | ▶ | $i++ while $peek->(';'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 2 | my $body = $stmt->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 2 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 2 | my @x = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 2 | ▶ | my @keys = keys %{ $arr{$an} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$arr{$an} || {}
MC/DC0%0/1
$arr{$an} || {}
$arr{$an}
Truth table50%1/2
A
A= $arr{$an}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | @keys = ( grep { !/\A-?\d+(?:\.\d+)?\z/ } @keys ) ? sort @keys : sort { $a <=> $b } @keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 2 | my $o = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | for my $key (@keys) { $var{$kv} = $key; $o .= $body->(@x) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | return $o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 66 | ▶ | if ( $k->[0] eq 'name' && $k->[1] =~ /\A(?:print|printf)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$k->[0] eq "name" and $k->[1] =~ /\A(?:print|printf)\z/
MC/DC50%1/2
$k->[0] eq "name" and $k->[1] =~ /\A(?:print|printf)\z/
$k->[0] eq "name"
$k->[1] =~ /\A(?:print|printf)\z/
Truth table66%2/3
A and B
A= $k->[0] eq "name"B= $k->[1] =~ /\A(?:print|printf)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 50 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 50 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 50 | my $at = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 50 | ▶ | if ( $peek->('(') ) { # print( a, b ) / printf( fmt, … ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | ▶ | my @p = eval { my @x = ( $or->() ); while ( $peek->(',') ) { $i++; push @x, $or->() } $take->(')'); @x }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 2 | ▶ | if ( @p && ( !$t[$i] || $peek->(';') || $peek->('}') ) ) { @items = @p } else { $i = $at } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
@p and !$t[$i] || &$peek(";") || &$peek("}")
not $t[$i] or &$peek(";") or &$peek("}")
not $t[$i] or &$peek(";")
MC/DC25%1/4
@p and !$t[$i] || &$peek(";") || &$peek("}")
@p
not $t[$i]
&$peek(";")
&$peek("}")
Truth table40%2/5
A and not(B) or C or D
A= @pB= not $t[$i]C= &$peek(";")D= &$peek("}")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 50 | ▶ | if ( !@items && $t[$i] && !$peek->(';') && !$peek->('}') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
not @items and $t[$i] and not &$peek(";") and not &$peek("}")
not @items and $t[$i] and not &$peek(";")
not @items and $t[$i]
MC/DC50%2/4
not @items and $t[$i] and not &$peek(";") and not &$peek("}")
not @items
$t[$i]
not &$peek(";")
not &$peek("}")
Truth table60%3/5
not(A) and B and not(C) and not(D)
A= not @itemsB= $t[$i]C= not &$peek(";")D= not &$peek("}")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 48 | push @items, $concat->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 46 | ▶ | while ( $peek->(',') ) { $i++; push @items, $concat->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 48 | ▶ | die "awk\n" if $t[$i] && !$peek->(';') && !$peek->('}') && !( $t[$i][0] eq 'name' && $t[$i][1] eq 'else' ); # print > datei, print | befehl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%6/12
$t[$i] and not &$peek(";") and not &$peek("}") and not $t[$i][0] eq "name" && $t[$i][1] eq "else"
$t[$i] and not &$peek(";") and not &$peek("}")
$t[$i] and not &$peek(";")
$t[$i][0] eq 'name' && $t[$i][1] eq 'else'
MC/DC20%1/5
$t[$i] and not &$peek(";") and not &$peek("}") and not $t[$i][0] eq "name" && $t[$i][1] eq "else"
$t[$i]
not &$peek(";")
not &$peek("}")
$t[$i][0] eq 'name'
$t[$i][1] eq 'else'
Truth table33%2/6
A and not(B) and not(C) and not(D && E)
A= $t[$i]B= not &$peek(";")C= not &$peek("}")D= $t[$i][0] eq 'name'E= $t[$i][1] eq 'else'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 47 | my $how = $k->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 87 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 87 | my @x = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 87 | my @v = map { $_->(@x) } @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 86 | ▶ | return sprintf( shift(@v) // '', @v ) if $how eq 'printf'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
shift @v // ""
MC/DC0%0/1
shift @v // ""
shift @v
Truth table50%1/2
A
A= shift @v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 75 | ▶ | return @v ? join( $ofs, @v ) . "\n" : "$x[0]\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 47 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # Zuweisung: [++|--]name[[k]] [= += -= *= /= %= ++ --] ausdruck | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 16 | my $pre; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if ( $peek->('++') || $peek->('--') ) { $pre = $t[ $i++ ][1] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
&$peek("++") or &$peek("--")
MC/DC0%0/2
&$peek("++") or &$peek("--")
&$peek("++")
&$peek("--")
Truth table33%1/3
A or B
A= &$peek("++")B= &$peek("--")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 16 | my $n = $t[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 16 | ▶ | die "awk\n" unless $n && $n->[0] eq 'name' && $n->[1] !~ /\A(?:NR|NF|FNR|getline|next|exit|delete|while|do|function|return)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$n and $n->[0] eq "name" and not $n->[1] =~ /\A(?:NR|NF|FNR|getline|next|exit|delete|while|do|function|return)\z/
$n and $n->[0] eq "name"
MC/DC33%1/3
$n and $n->[0] eq "name" and not $n->[1] =~ /\A(?:NR|NF|FNR|getline|next|exit|delete|while|do|function|return)\z/
$n
$n->[0] eq "name"
not $n->[1] =~ /\A(?:NR|NF|FNR|getline|next|exit|delete|while|do|function|return)\z/
Truth table50%2/4
A and B and not(C)
A= $nB= $n->[0] eq "name"C= not $n->[1] =~ /\A(?:NR|NF|FNR|getline|next|exit|delete|while|do|function|return)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 15 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 15 | my $ke; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 15 | ▶ | if ( $peek->('[') ) { $i++; $ke = $or->(); $take->(']') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 15 | my $name = $n->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 15 | ▶ | my $get = sub { my $key = shift; defined $key ? ( $arr{$name} || {} )->{$key} // '' : $var{$name} // '' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
Branch: 1 branch
Condition100%6/6
+($arr{$name} || {})->{$key} // ""
$arr{$name} || {}
$var{$name} // ""
MC/DC100%1/1
+($arr{$name} || {})->{$key} // ""
$arr{$name}
MC/DC100%1/1
$var{$name} // ""
$var{$name}
Truth table100%2/2
A
A= $arr{$name}
Truth table100%2/2
A
A= $var{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ($pre) { my $d = $pre eq '++' ? 1 : -1; return sub { my $key = $ke ? $ke->(@_) : undef; $setv->( $name, $key, $fmt->( $num->( $get->($key) ) + $d ) ); '' } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.6
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 15 | ▶ | my $op = $t[$i] && $t[$i][0] eq 'op' ? $t[$i][1] : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$t[$i] and $t[$i][0] eq "op"
MC/DC0%0/2
$t[$i] and $t[$i][0] eq "op"
$t[$i]
$t[$i][0] eq "op"
Truth table33%1/3
A and B
A= $t[$i]B= $t[$i][0] eq "op"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 15 | ▶ | if ( $op eq '++' || $op eq '--' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$op eq "++" or $op eq "--"
MC/DC50%1/2
$op eq "++" or $op eq "--"
$op eq "++"
$op eq "--"
Truth table66%2/3
A or B
A= $op eq "++"B= $op eq "--"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 3 | ▶ | my $d = $op eq '++' ? 1 : -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 3 | ▶ | return sub { my $key = $ke ? $ke->(@_) : undef; $setv->( $name, $key, $fmt->( $num->( $get->($key) ) + $d ) ); '' }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 12 | ▶ | die "awk\n" unless $op =~ /\A(?:=|\+=|-=|\*=|\/=|%=)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 11 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 11 | my $e = $or->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 20 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=25.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 20 | ▶ | my $key = $ke ? $ke->(@_) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 20 | my $v = $e->(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 20 | ▶ | if ( $op ne '=' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 13 | my ( $x, $y ) = ( $num->( $get->($key) ), $num->($v) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 13 | ▶ | die "awk: cmd. line:1: fatal: division by zero attempted\n" if ( $op eq '/=' || $op eq '%=' ) && $y == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$op eq "/=" || $op eq "%=" and $y == 0
$op eq "/=" or $op eq "%="
MC/DC0%0/3
$op eq "/=" || $op eq "%=" and $y == 0
$op eq "/="
$op eq "%="
$y == 0
Truth table20%1/5
A or B and C
A= $op eq "/="B= $op eq "%="C= $y == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 13 | ▶ | $v = $fmt->( $op eq '+=' ? $x + $y : $op eq '-=' ? $x - $y : $op eq '*=' ? $x * $y : $op eq '/=' ? $x / $y : $x - $y * int( $x / $y ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 20 | $setv->( $name, $key, $v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 20 | ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my ( @rules, @begin, @end ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | while ( $i < @t ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if ( $peek->(';') ) { $i++; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if ( $t[$i][0] eq 'name' && $t[$i][1] =~ /\A(BEGIN|END)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
$t[$i][0] eq "name" and $t[$i][1] =~ /\A(BEGIN|END)\z/
$t[$i][0] eq "name" and $t[$i][1] =~ /\A(BEGIN|END)\z/
MC/DC100%2/2
$t[$i][0] eq "name" and $t[$i][1] =~ /\A(BEGIN|END)\z/
$t[$i][0] eq "name"
$t[$i][1] =~ /\A(BEGIN|END)\z/
MC/DC0%0/2
$t[$i][0] eq "name" and $t[$i][1] =~ /\A(BEGIN|END)\z/
$t[$i][0] eq "name"
$t[$i][1] =~ /\A(BEGIN|END)\z/
Truth table100%3/3
A and B
A= $t[$i][0] eq "name"B= $t[$i][1] =~ /\A(BEGIN|END)\z/
Truth table0%0/3
A and B
A= $t[$i][0] eq "name"B= $t[$i][1] =~ /\A(BEGIN|END)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | my $which = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $take->('{'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my $b = $block->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $take->('}'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | push @{ $which eq 'BEGIN' ? \@begin : \@end }, $b; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | my $pat = $peek->('{') ? undef : $or->(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my $act; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | if ( $peek->('{') ) { $i++; $act = $block->(); $take->('}') } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | push @rules, [ $pat, $act ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | $i++ while $peek->(';'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | return (undef) unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $out = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $nr = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my ( $last, @lastf ) = (''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $run = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $out .= join '', map { $_->( '', [], 0 ) } @begin; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | for my $l ( @rules || @end ? @$lines : () ) { # nur BEGIN: awk liest keine Eingabe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
@rules or @end
@rules or @end
MC/DC100%2/2
@rules or @end
@rules
@end
MC/DC0%0/2
@rules or @end
@rules
@end
Truth table100%3/3
A or B
A= @rulesB= @end
Truth table0%0/3
A or B
A= @rulesB= @end
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $nr++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | my @f = !defined $sep || $sep eq ' ' ? split( ' ', $l ) : length($sep) == 1 ? split( /\Q$sep\E/, $l, -1 ) : split( /$sep/, $l, -1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition33%2/6
not defined $sep or $sep eq " "
not defined $sep or $sep eq " "
MC/DC50%1/2
not defined $sep or $sep eq " "
not defined $sep
$sep eq " "
MC/DC0%0/2
not defined $sep or $sep eq " "
not defined $sep
$sep eq " "
Truth table66%2/3
not(A) or B
A= not defined $sepB= $sep eq " "
Truth table0%0/3
not(A) or B
A= not defined $sepB= $sep eq " "
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ( $last, @lastf ) = ( $l, @f ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | for my $r (@rules) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my ( $pat, $act ) = @$r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | next if $pat && !$pat->( $l, \@f, $nr ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
$pat and not &$pat($l, \@f, $nr)
$pat and not &$pat($l, \@f, $nr)
MC/DC100%2/2
$pat and not &$pat($l, \@f, $nr)
$pat
not &$pat($l, \@f, $nr)
MC/DC0%0/2
$pat and not &$pat($l, \@f, $nr)
$pat
not &$pat($l, \@f, $nr)
Truth table100%3/3
A and not(B)
A= $patB= not &$pat($l, \@f, $nr)
Truth table0%0/3
A and not(B)
A= $patB= not &$pat($l, \@f, $nr)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | $out .= $act ? $act->( $l, \@f, $nr ) : "$l\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | $out .= join '', map { $_->( $last, \@lastf, $nr ) } @end; # END: der letzte Satz und NR bleiben | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | if ( !$run ) { ( my $e = $@ ) =~ s/\s+\z//; return ( $out . $e, 0 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $out =~ s/\n\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | return ( $out, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # tr [-c|-C] [-d] [-s] SATZ1 [SATZ2] wie GNU tr: Escapes, Bereiche a-z, Klassen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # [:alpha:] …; SATZ2 wird mit seinem letzten Zeichen aufgefuellt. [=c=] und [c*n]: Luecke. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 84 | my %TR_CLASS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | alpha => qr/[[:alpha:]]/, digit => qr/[0-9]/, alnum => qr/[[:alnum:]]/, upper => qr/[A-Z]/, lower => qr/[a-z]/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | space => qr/\s/, blank => qr/[ \t]/, punct => qr/[[:punct:]]/, print => qr/[^\x00-\x1f\x7f]/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | graph => qr/[^\x00-\x20\x7f]/, cntrl => qr/[\x00-\x1f\x7f]/, xdigit => qr/[0-9A-Fa-f]/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 8 | ▶ | sub _tr_set { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tr_set: called CC=14 SCAR=28.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 8 | my ($s) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 8 | my %esc = ( n => "\n", t => "\t", r => "\r", '\\' => '\\', a => "\a", b => "\b", f => "\f", v => "\x0b" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 8 | my @c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 8 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 8 | ▶ | while ( $i < length $s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 9 | ▶ | if ( substr( $s, $i ) =~ /\A\[:(\w+):\]/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 2 | ▶ | my $re = $TR_CLASS{$1} // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$TR_CLASS{$1} // (return)
MC/DC0%0/1
$TR_CLASS{$1} // (return)
$TR_CLASS{$1}
Truth table50%1/2
A
A= $TR_CLASS{$1}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 2 | push @c, grep { $_ =~ $re } map { chr } 0 .. 127; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 2 | $i += length "[:$1:]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 7 | ▶ | return if substr( $s, $i ) =~ /\A\[(?:=.=|.\*\d*\])/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 7 | my $c = substr( $s, $i, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 7 | ▶ | if ( $c eq '\\' && $i + 1 < length $s ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$c eq "\\" and $i + 1 < length $s
MC/DC50%1/2
$c eq "\\" and $i + 1 < length $s
$c eq "\\"
$i + 1 < length $s
Truth table66%2/3
A and B
A= $c eq "\\"B= $i + 1 < length $s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 1 | my $n = substr( $s, $i + 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | if ( $n =~ /\A([0-7]{1,3})/ ) { $c = chr oct $1; $i += 1 + length $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | ▶ | else { $c = $esc{ substr( $n, 0, 1 ) } // substr( $n, 0, 1 ); $i += 2 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$esc{substr($n, 0, 1)} // substr($n, 0, 1)
MC/DC0%0/2
$esc{substr($n, 0, 1)} // substr($n, 0, 1)
$esc{substr($n, 0, 1)}
substr($n, 0, 1)
Truth table33%1/3
A // B
A= $esc{substr($n, 0, 1)}B= substr($n, 0, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 6 | else { $i++ } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 7 | ▶ | if ( substr( $s, $i, 1 ) eq '-' && $i + 1 < length $s ) { # Bereich | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
substr($s, $i, 1) eq "-" and $i + 1 < length $s
MC/DC50%1/2
substr($s, $i, 1) eq "-" and $i + 1 < length $s
substr($s, $i, 1) eq "-"
$i + 1 < length $s
Truth table66%2/3
A and B
A= substr($s, $i, 1) eq "-"B= $i + 1 < length $s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 3 | my $to = substr( $s, $i + 1, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 3 | $i += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | if ( $to eq '\\' ) { my $n = substr( $s, $i, 1 ); $to = $esc{$n} // $n; $i++ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$esc{$n} // $n
MC/DC0%0/2
$esc{$n} // $n
$esc{$n}
$n
Truth table0%0/3
A // B
A= $esc{$n}B= $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 3 | ▶ | return if ord $to < ord $c; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | push @c, map { chr } ord($c) .. ord($to); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 4 | push @c, $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 8 | return \@c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 5 | ▶ | sub _tr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tr: called CC=32 SCAR=37.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 5 | my ( $text, @a ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 5 | my ( %o, @sets ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 5 | for my $x (@a) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 11 | ▶ | if ( $x =~ /\A-([cCdst]+)\z/ ) { $o{ $_ eq 'C' ? 'c' : $_ } = 1 for split //, $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | elsif ( $x =~ /\A--/ ) { return (undef) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 8 | else { push @sets, $x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 5 | ▶ | return ( 'tr: missing operand', 0 ) unless @sets; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 5 | ▶ | my $s1 = _tr_set( $sets[0] ) // return (undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_tr_set($sets[0]) // (return undef)
MC/DC0%0/1
_tr_set($sets[0]) // (return undef)
_tr_set($sets[0])
Truth table50%1/2
A
A= _tr_set($sets[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 5 | ▶ | my $s2 = defined $sets[1] ? _tr_set( $sets[1] ) // return (undef) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
_tr_set($sets[1]) // (return undef)
MC/DC0%0/1
_tr_set($sets[1]) // (return undef)
_tr_set($sets[1])
Truth table50%1/2
A
A= _tr_set($sets[1])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 5 | my %in1 = map { $_ => 1 } @$s1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 5 | ▶ | my $m1 = $o{c} ? sub { !$in1{ $_[0] } } : sub { $in1{ $_[0] } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 5 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 5 | ▶ | if ( $o{d} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 1 | @out = grep { !$m1->($_) } split //, $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ▶ | elsif ( $s2 && !$o{d} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$s2 and not $o{"d"}
MC/DC50%1/2
$s2 and not $o{"d"}
$s2
not $o{"d"}
Truth table66%2/3
A and not(B)
A= $s2B= not $o{"d"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 3 | ▶ | return ( 'tr: when not truncating set1, string2 must be non-empty', 0 ) unless @$s2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 3 | my %map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 3 | ▶ | if ( $o{c} ) { %map = () } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 2 | ▶ | else { $map{ $s1->[$_] } //= $s2->[ $_ < @$s2 ? $_ : -1 ] for 0 .. $#$s1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$map{$s1->[$_]} //= $$s2[$_ < @$s2 ? $_ : -1]
MC/DC0%0/2
$map{$s1->[$_]} //= $$s2[$_ < @$s2 ? $_ : -1]
$map{$s1->[$_]}
$$s2[$_ < @$s2 ? $_ : -1]
Truth table33%1/3
A //= B
A= $map{$s1->[$_]}B= $$s2[$_ < @$s2 ? $_ : -1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 3 | ▶ | @out = map { $o{c} ? ( $m1->($_) ? $s2->[-1] : $_ ) : exists $map{$_} ? $map{$_} : $_ } split //, $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 1 | elsif ( $o{s} ) { @out = split //, $text } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | else { return ( "tr: missing operand after '$sets[0]'", 0 ) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 5 | ▶ | if ( $o{s} ) { # Wiederholungen aus dem letzten Satz zusammenziehen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 1 | ▶ | my %sq = map { $_ => 1 } @{ $s2 && !$o{d} ? $s2 : $s1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$s2 and not $o{"d"}
MC/DC0%0/2
$s2 and not $o{"d"}
$s2
not $o{"d"}
Truth table33%1/3
A and not(B)
A= $s2B= not $o{"d"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | my $msq = $s2 && !$o{d} ? sub { $sq{ $_[0] } } : $m1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.7
Branch: 1 branch
Condition33%1/3
$s2 and not $o{"d"}
MC/DC0%0/2
$s2 and not $o{"d"}
$s2
not $o{"d"}
Truth table33%1/3
A and not(B)
A= $s2B= not $o{"d"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | my @z; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 1 | ▶ | for (@out) { push @z, $_ unless @z && $z[-1] eq $_ && $msq->($_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@z and $z[-1] eq $_ and &$msq($_)
@z and $z[-1] eq $_
MC/DC66%2/3
@z and $z[-1] eq $_ and &$msq($_)
@z
$z[-1] eq $_
&$msq($_)
Truth table75%3/4
A and B and C
A= @zB= $z[-1] eq $_C= &$msq($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 1 | @out = @z; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 5 | return ( join( '', @out ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # Grundlegender regulaerer Ausdruck (grep ohne -E) als Perl: \| \( \) \+ \? \{ \} sind | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # besonders, ohne \ stehen | ( ) + ? { } fuer sich | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 89 | ▶ | sub _bre { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bre: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 89 | my ($p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 89 | my $out = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 89 | ▶ | while ( $p =~ /\G(?:\\(.)|([|()+?{}])|(.))/gcs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 569 | ▶ | if ( defined $1 ) { my $c = $1; $out .= $c =~ /\A[|()+?{}]\z/ ? $c : "\\$c" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 4 | elsif ( defined $2 ) { $out .= "\\$2" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 564 | else { $out .= $3 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 89 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 250 | ▶ | sub filter_output { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter_output: called CC=108 SCAR=62.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 250 | my ( $text, $argv ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 250 | my ( $cmd, @a ) = @$argv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 250 | ▶ | my @lines = length $text ? split /\n/, $text, -1 : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 250 | ▶ | pop @lines if @lines && $lines[-1] eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@lines and $lines[-1] eq ""
MC/DC100%2/2
@lines and $lines[-1] eq ""
@lines
$lines[-1] eq ""
Truth table100%3/3
A and B
A= @linesB= $lines[-1] eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 250 | ▶ | if ( $cmd eq 'grep' || $cmd eq 'egrep' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cmd eq "grep" or $cmd eq "egrep"
MC/DC50%1/2
$cmd eq "grep" or $cmd eq "egrep"
$cmd eq "grep"
$cmd eq "egrep"
Truth table66%2/3
A or B
A= $cmd eq "grep"B= $cmd eq "egrep"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 87 | my %f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | my @pat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 87 | my %n = ( A => 0, B => 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 87 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 119 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 119 | ▶ | if ( $x =~ /\A-([ivEFwcnHhs]*)([ABCm])(\d*)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 7 | my ( $fl, $o, $num ) = ( $1, $2, $3 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 7 | $f{$_} = 1 for split //, $fl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 7 | ▶ | my $v = length $num ? $num : shift(@a) // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
shift @a // 0
MC/DC0%0/1
shift @a // 0
shift @a
Truth table50%1/2
A
A= shift @a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 7 | ▶ | $v = $v =~ /\A(\d+)\z/ ? 0 + $1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 7 | ▶ | if ( $o eq 'C' ) { @n{qw( A B )} = ( $v, $v ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 1 | elsif ( $o eq 'm' ) { $n{m} = $v } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 5 | else { $n{$o} = $v } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 7 | ▶ | $f{ctx} = 1 if $o ne 'm'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 7 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 112 | ▶ | if ( $x =~ /\A-([ivEFwcnHhs]+)\z/ ) { $f{$_} = 1 for split //, $1; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 90 | ▶ | if ( $x eq '-e' ) { push @pat, shift @a; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 88 | push @pat, $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 87 | ▶ | return ( "Usage: grep [OPTION]... PATTERNS [FILE]...", 0 ) unless @pat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | my @re = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 87 | my $p = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 90 | ▶ | $p = quotemeta $p if $f{F}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 90 | ▶ | $p = _bre($p) unless $f{E} || $f{F} || $cmd eq 'egrep'; # BRE: \| ist Alternative, { steht fuer sich | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$f{"E"} or $f{"F"} or $cmd eq "egrep"
$f{"E"} or $f{"F"}
MC/DC33%1/3
$f{"E"} or $f{"F"} or $cmd eq "egrep"
$f{"E"}
$f{"F"}
$cmd eq "egrep"
Truth table50%2/4
A or B or C
A= $f{"E"}B= $f{"F"}C= $cmd eq "egrep"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 90 | ▶ | $p = "\\b$p\\b" if $f{w}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 90 | ▶ | my $re = eval { $f{i} ? qr/$p/i : qr/$p/ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 90 | ▶ | $re // qr/\Q$_\E/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$re // qr/\Q$_\E/
MC/DC0%0/1
$re // qr/\Q$_\E/
$re
Truth table50%1/2
A
A= $re
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } @pat; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 87 | ▶ | my @idx = grep { my $l = $lines[$_]; my $m = grep { $l =~ $_ } @re; $f{v} ? !$m : $m } 0 .. $#lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 87 | ▶ | @idx = @idx[ 0 .. $n{m} - 1 ] if defined $n{m} && @idx > $n{m}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $n{"m"} and @idx > $n{"m"}
MC/DC50%1/2
defined $n{"m"} and @idx > $n{"m"}
defined $n{"m"}
@idx > $n{"m"}
Truth table66%2/3
A and B
A= defined $n{"m"}B= @idx > $n{"m"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 87 | ▶ | return ( scalar(@idx), @idx ? 1 : 0 ) if $f{c}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 78 | my %hit = map { $_ => 1 } @idx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 78 | my ( @out, $last ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 78 | ▶ | for my $i ( $f{ctx} ? ( map { ( $_ - $n{B} < 0 ? 0 : $_ - $n{B} ) .. ( $_ + $n{A} > $#lines ? $#lines : $_ + $n{A} ) } @idx ) : @idx ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 70 | ▶ | next if defined $last && $i <= $last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $last and $i <= $last
MC/DC0%0/2
defined $last and $i <= $last
defined $last
$i <= $last
Truth table66%2/3
A and B
A= defined $lastB= $i <= $last
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 70 | ▶ | push @out, '--' if $f{ctx} && defined $last && $i > $last + 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$f{"ctx"} and defined $last and $i > $last + 1
$f{"ctx"} and defined $last
MC/DC100%3/3
$f{"ctx"} and defined $last and $i > $last + 1
$f{"ctx"}
defined $last
$i > $last + 1
Truth table100%4/4
A and B and C
A= $f{"ctx"}B= defined $lastC= $i > $last + 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 70 | ▶ | push @out, ( $f{n} ? ( $i + 1 ) . ( $hit{$i} ? ':' : '-' ) : '' ) . $lines[$i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 70 | $last = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 78 | ▶ | return ( join( "\n", @out ), @idx ? 1 : 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 163 | ▶ | if ( $cmd eq 'head' || $cmd eq 'tail' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$cmd eq "head" or $cmd eq "tail"
MC/DC100%2/2
$cmd eq "head" or $cmd eq "tail"
$cmd eq "head"
$cmd eq "tail"
Truth table100%3/3
A or B
A= $cmd eq "head"B= $cmd eq "tail"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 27 | my $n = 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 27 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 29 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 29 | ▶ | if ( $x eq '-n' || $x eq '--lines' ) { $n = shift(@a) // 10 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition60%3/5
$x eq "-n" or $x eq "--lines"
shift @a // 10
MC/DC50%1/2
$x eq "-n" or $x eq "--lines"
$x eq "-n"
$x eq "--lines"
MC/DC0%0/1
shift @a // 10
shift @a
Truth table66%2/3
A or B
A= $x eq "-n"B= $x eq "--lines"
Truth table50%1/2
A
A= shift @a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 12 | ▶ | elsif ( $x =~ /\A(?:-n|--lines=)([-+]?\d+)\z/ || $x =~ /\A-(\d+)\z/ ) { $n = $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$x =~ /\A(?:-n|--lines=)([-+]?\d+)\z/ or $x =~ /\A-(\d+)\z/
MC/DC100%2/2
$x =~ /\A(?:-n|--lines=)([-+]?\d+)\z/ or $x =~ /\A-(\d+)\z/
$x =~ /\A(?:-n|--lines=)([-+]?\d+)\z/
$x =~ /\A-(\d+)\z/
Truth table100%3/3
A or B
A= $x =~ /\A(?:-n|--lines=)([-+]?\d+)\z/B= $x =~ /\A-(\d+)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | elsif ( $x =~ /\A-c(\d*)\z/ ) { # Bytes statt Zeilen: -cN oder -c N | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 4 | ▶ | my $c = length $1 ? $1 : shift(@a) // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
shift @a // 0
MC/DC0%0/1
shift @a // 0
shift @a
Truth table50%1/2
A
A= shift @a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 4 | ▶ | $c = 0 + ( $c =~ /(\d+)/ ? $1 : 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 4 | ▶ | return ( $cmd eq 'head' ? substr( $text, 0, $c ) : substr( $text, length($text) > $c ? -$c : 0 ), 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 23 | ▶ | return ( "$cmd: invalid number of lines: '$n'", 0 ) unless $n =~ /\A([-+]?)(\d+)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 23 | my ( $sg, $k ) = ( $1, 0 + $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 23 | my @l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 23 | ▶ | if ( $cmd eq 'head' ) { # head -n -K: alles ausser den letzten K | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 19 | ▶ | my $last = $sg eq '-' ? @lines - $k - 1 : ( $k < @lines ? $k : @lines ) - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 19 | @l = @lines[ 0 .. $last ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | else { # tail -n +K: ab Zeile K | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 4 | ▶ | @l = $sg eq '+' ? @lines[ ( $k > 0 ? $k - 1 : 0 ) .. $#lines ] : @lines[ ( @lines > $k ? @lines - $k : 0 ) .. $#lines ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 23 | return ( join( "\n", @l ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 136 | ▶ | return ( scalar(@lines), 1 ) if $cmd eq 'wc' && "@a" eq '-l'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$cmd eq "wc" and join($", @a) eq "-l"
MC/DC100%2/2
$cmd eq "wc" and join($", @a) eq "-l"
$cmd eq "wc"
join($", @a) eq "-l"
Truth table100%3/3
A and B
A= $cmd eq "wc"B= join($", @a) eq "-l"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 124 | ▶ | if ( $cmd eq 'wc' && !grep { !/\A-[lcwm]+\z/ } @a ) { # wc -l/-c/-w/-m, kombiniert bzw. alle; Bytes genau (aus einer Pipe ohne letztes Zeilenende) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$cmd eq "wc" and not grep({not /\A-[lcwm]+\z/;} @a)
MC/DC50%1/2
$cmd eq "wc" and not grep({not /\A-[lcwm]+\z/;} @a)
$cmd eq "wc"
not grep({not /\A-[lcwm]+\z/;} @a)
Truth table66%2/3
A and not(B)
A= $cmd eq "wc"B= not grep({not /\A-[lcwm]+\z/;} @a)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 10 | my $nw = () = $text =~ /\S+/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 10 | my %n = ( l => scalar(@lines), w => $nw, m => length $text, c => length Encode::encode( 'UTF-8', $text ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 10 | ▶ | my @want = @a ? map { /\A-(\w+)\z/ ? split //, $1 : () } @a : qw( l w c ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 10 | return ( join( ' ', map { $n{$_} } grep { my $k = $_; grep { $_ eq $k } @want } qw( l w m c ) ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 114 | ▶ | if ( $cmd eq 'sort' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 2 | ▶ | my %o = map { $_ => 1 } map { /\A-(\w+)\z/ ? split( //, $1 ) : () } @a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 2 | my %u = ( K => 1024, M => 1024**2, G => 1024**3, T => 1024**4 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 2 | ▶ | my $hv = sub { my ( $x, $s ) = $_[0] =~ /(-?\d+(?:\.\d+)?)([KMGT]?)/; $x //= 0; $s ? $x * $u{$s} : $x }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
Branch: 1 branch
Condition50%1/2
$x //= 0
MC/DC0%0/1
$x //= 0
$x
Truth table50%1/2
A
A= $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 5 | ▶ | my @s = $o{h} ? sort { $hv->($a) <=> $hv->($b) } @lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | : $o{n} ? sort { ( ( $a =~ /(-?\d+)/ )[0] // 0 ) <=> ( ( $b =~ /(-?\d+)/ )[0] // 0 ) } @lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/4
($a =~ /(-?\d+)/)[0] // 0
($b =~ /(-?\d+)/)[0] // 0
MC/DC0%0/1
($a =~ /(-?\d+)/)[0] // 0
($a =~ /(-?\d+)/)[0]
MC/DC0%0/1
($b =~ /(-?\d+)/)[0] // 0
($b =~ /(-?\d+)/)[0]
Truth table0%0/2
A
A= ($a =~ /(-?\d+)/)[0]
Truth table0%0/2
A
A= ($b =~ /(-?\d+)/)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | : sort @lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 2 | ▶ | @s = reverse @s if $o{r}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | if ( $o{u} ) { my %seen; @s = grep { !$seen{$_}++ } @s } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 2 | return ( join( "\n", @s ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 112 | ▶ | if ( $cmd eq 'uniq' ) { # -c zaehlt (wie GNU: %7d), -d nur doppelte, -u nur einzelne | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my %o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | for (@a) { return (undef) unless /\A-([cdu]+)\z/; $o{$_} = 1 for split //, $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my @u; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | for (@lines) { if ( @u && $u[-1][0] eq $_ ) { $u[-1][1]++ } else { push @u, [ $_, 1 ] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@u and $u[-1][0] eq $_
MC/DC0%0/2
@u and $u[-1][0] eq $_
@u
$u[-1][0] eq $_
Truth table0%0/3
A and B
A= @uB= $u[-1][0] eq $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | @u = grep { $_->[1] > 1 } @u if $o{d}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | @u = grep { $_->[1] == 1 } @u if $o{u}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | return ( join( "\n", map { $o{c} ? sprintf( '%7d %s', $_->[1], $_->[0] ) : $_->[0] } @u ), 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 112 | ▶ | return _cut( \@lines, @a ) if $cmd eq 'cut'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 109 | ▶ | return _awk( \@lines, @a ) if $cmd eq 'awk'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 58 | ▶ | return _tr( join( "\n", @lines ), @a ) if $cmd eq 'tr'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 53 | ▶ | if ( $cmd eq 'fold' ) { # fold [-b] [-s] [-w N]: Zeilen auf N Zeichen umbrechen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my ( $w, $sp ) = ( 80, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | while (@a) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $x = shift @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | ▶ | if ( $x =~ /\A-w(\d+)\z/ || $x =~ /\A--width=(\d+)\z/ ) { $w = $1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition0%0/3
$x =~ /\A-w(\d+)\z/ or $x =~ /\A--width=(\d+)\z/
MC/DC0%0/2
$x =~ /\A-w(\d+)\z/ or $x =~ /\A--width=(\d+)\z/
$x =~ /\A-w(\d+)\z/
$x =~ /\A--width=(\d+)\z/
Truth table0%0/3
A or B
A= $x =~ /\A-w(\d+)\z/B= $x =~ /\A--width=(\d+)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | elsif ( $x eq '-w' ) { $w = shift(@a) // '' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @a // ""
MC/DC0%0/1
shift @a // ""
shift @a
Truth table0%0/2
A
A= shift @a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | elsif ( $x =~ /\A-(\d+)\z/ ) { $w = $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | elsif ( $x =~ /\A-[bs]+\z/ ) { $sp = 1 if $x =~ /s/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | else { return (undef) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | return ( "fold: invalid number of columns: '$w'", 0 ) unless $w =~ /\A\d+\z/ && $w > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$w =~ /\A\d+\z/ and $w > 0
MC/DC0%0/2
$w =~ /\A\d+\z/ and $w > 0
$w =~ /\A\d+\z/
$w > 0
Truth table0%0/3
A and B
A= $w =~ /\A\d+\z/B= $w > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my @o; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | for my $l (@lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $r = $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | while ( length $r > $w ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my $cut = $w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | if ( $sp && substr( $r, 0, $w ) =~ /.*\s/s ) { $cut = $+[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sp and substr($r, 0, $w) =~ /.*\s/s
MC/DC0%0/2
$sp and substr($r, 0, $w) =~ /.*\s/s
$sp
substr($r, 0, $w) =~ /.*\s/s
Truth table0%0/3
A and B
A= $spB= substr($r, 0, $w) =~ /.*\s/s
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | push @o, substr( $r, 0, $cut ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | $r = substr( $r, $cut ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | push @o, $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | return ( join( "\n", @o ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 53 | ▶ | return ( $text, 1 ) if $cmd eq 'cat' && !@a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$cmd eq "cat" and not @a
MC/DC0%0/2
$cmd eq "cat" and not @a
$cmd eq "cat"
not @a
Truth table33%1/3
A and not(B)
A= $cmd eq "cat"B= not @a
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 53 | return (undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 84 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||