| 1 | #!/usr/bin/perl -w | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package Sort::ArrayOfArrays; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use vars qw(@ISA @EXPORT_OK $VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | @EXPORT_OK = qw(sort_it); | |||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | $VERSION = '1.00'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 5 | ▶ | my @PASSED_ARGS = (ref $_[0] eq 'HASH') ? %{$_[0]} : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | my @DEFAULT_ARGS = ( | |||||||||||||||||||||||||||||||||||||||||
| 16 | header_row => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 17 | results => [], | ||||||||||||||||||||||||||||||||||||||||||
| 18 | sort_column => '', | ||||||||||||||||||||||||||||||||||||||||||
| 19 | sort_code => [], | ||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | my %ARGS = (@DEFAULT_ARGS, @PASSED_ARGS); | |||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | my $self = bless \%ARGS, $type; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | ▶ | sub sort_it { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_it: called CC=9 SCAR=25.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | ▶ | unless(ref $self eq __PACKAGE__) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $self = __PACKAGE__->new({ | |||||||||||||||||||||||||||||||||||||||||
| 31 | results => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 32 | sort_column => $_[0], | ||||||||||||||||||||||||||||||||||||||||||
| 33 | sort_code => $_[1], | ||||||||||||||||||||||||||||||||||||||||||
| 34 | header_row => $_[2], | ||||||||||||||||||||||||||||||||||||||||||
| 35 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | ▶ | die "\$self->{results} is required" unless($self->{results}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | ▶ | die "\$self->{results} needs to be an array of arrays" unless(ref $self->{results} eq 'ARRAY' && $self->{results}->[0] && ref $self->{results}->[0] eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $self->{"results"} eq "ARRAY" and $self->{"results"}[0] and ref $self->{"results"}[0] eq "ARRAY"
ref $self->{"results"} eq "ARRAY" and $self->{"results"}[0]
MC/DC0%0/3
ref $self->{"results"} eq "ARRAY" and $self->{"results"}[0] and ref $self->{"results"}[0] eq "ARRAY"
ref $self->{"results"} eq "ARRAY"
$self->{"results"}[0]
ref $self->{"results"}[0] eq "ARRAY"
Truth table25%1/4
A and B and C
A= ref $self->{"results"} eq "ARRAY"B= $self->{"results"}[0]C= ref $self->{"results"}[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 5 | ▶ | if($self->{header_row}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $self->{zero_row} = shift @{$self->{results}}; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 5 | $self->{rows} = (@{$self->{results}} - 1); | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 5 | $self->make_sort_code_ref; | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 5 | my $sort_method = $self->{sort_code_ref}; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | my @temp = (0 .. $self->{rows}); | |||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | @temp = sort $sort_method @temp; | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | my $return = []; | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | ▶ | for(my $i=0;$i<@temp;$i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 15 | $return->[$i] = $self->{results}->[$temp[$i]]; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 5 | ▶ | if($self->{header_row}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | unshift @{$return}, $self->{zero_row}; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | delete $self->{zero_row}; | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | $self->{results} = $return; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 5 | return $return; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 5 | ▶ | sub make_sort_code_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_sort_code_text: called CC=42 SCAR=55.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 5 | ▶ | return if($self->{sort_code_text}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | my $total_sorts = 0; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | foreach my $this_sort_column (split /\s*,\s*/, $self->{sort_column}) { | |||||||||||||||||||||||||||||||||||||||||
| 72 | 7 | $total_sorts++; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 7 | my $col = abs($this_sort_column); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 7 | ▶ | if($self->{sort_code} && ref $self->{sort_code}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"sort_code"} and ref $self->{"sort_code"}
MC/DC0%0/2
$self->{"sort_code"} and ref $self->{"sort_code"}
$self->{"sort_code"}
ref $self->{"sort_code"}
Truth table33%1/3
A and B
A= $self->{"sort_code"}B= ref $self->{"sort_code"}
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 7 | ▶ | if(ref $self->{sort_code} eq 'HASH' && $self->{sort_code}->{$col}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
ref $self->{"sort_code"} eq "HASH" and $self->{"sort_code"}{$col}
MC/DC0%0/2
ref $self->{"sort_code"} eq "HASH" and $self->{"sort_code"}{$col}
ref $self->{"sort_code"} eq "HASH"
$self->{"sort_code"}{$col}
Truth table33%1/3
A and B
A= ref $self->{"sort_code"} eq "HASH"B= $self->{"sort_code"}{$col}
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if(ref $self->{sort_code}->{$col}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | die "any ref for \$self->{sort_code}->{$col} needs to be an CODE ref" unless(ref $self->{sort_code}->{$col} eq 'CODE'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $self->{sort_code_ref} = $self->{sort_code}->{$col}; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | ▶ | } elsif(ref $self->{sort_code} eq 'ARRAY' && $self->{sort_code}->[$col]) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self->{"sort_code"} eq "ARRAY" and $self->{"sort_code"}[$col]
MC/DC0%0/2
ref $self->{"sort_code"} eq "ARRAY" and $self->{"sort_code"}[$col]
ref $self->{"sort_code"} eq "ARRAY"
$self->{"sort_code"}[$col]
Truth table33%1/3
A and B
A= ref $self->{"sort_code"} eq "ARRAY"B= $self->{"sort_code"}[$col]
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if(ref $self->{sort_code}->[$col]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | die "any ref for \$self->{sort_code}->[$col] needs to be an CODE ref" unless(ref $self->{sort_code}->[$col] eq 'CODE'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $self->{sort_code_ref} = $self->{sort_code}->[$col]; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 5 | $self->{sort_code_text} = "sub {\n";#"}" | |||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | my $this_sort = 0; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 5 | foreach my $this_sort_column (split /\s*,\s*/, $self->{sort_column}) { | |||||||||||||||||||||||||||||||||||||||||
| 94 | 7 | $this_sort++; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 7 | my $this_sort_method; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 7 | ▶ | if($self->{sort_code} && ref $self->{sort_code}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"sort_code"} and ref $self->{"sort_code"}
MC/DC0%0/2
$self->{"sort_code"} and ref $self->{"sort_code"}
$self->{"sort_code"}
ref $self->{"sort_code"}
Truth table33%1/3
A and B
A= $self->{"sort_code"}B= ref $self->{"sort_code"}
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 7 | ▶ | if(ref $self->{sort_code} eq 'HASH' && $self->{sort_code}->{$this_sort_column}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
ref $self->{"sort_code"} eq "HASH" and $self->{"sort_code"}{$this_sort_column}
MC/DC0%0/2
ref $self->{"sort_code"} eq "HASH" and $self->{"sort_code"}{$this_sort_column}
ref $self->{"sort_code"} eq "HASH"
$self->{"sort_code"}{$this_sort_column}
Truth table33%1/3
A and B
A= ref $self->{"sort_code"} eq "HASH"B= $self->{"sort_code"}{$this_sort_column}
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $this_sort_method = $self->{sort_code}->{$this_sort_column}; | |||||||||||||||||||||||||||||||||||||||||
| 99 | ▶ | } elsif(ref $self->{sort_code} eq 'ARRAY' && $self->{sort_code}->[$this_sort_column]) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self->{"sort_code"} eq "ARRAY" and $self->{"sort_code"}[$this_sort_column]
MC/DC0%0/2
ref $self->{"sort_code"} eq "ARRAY" and $self->{"sort_code"}[$this_sort_column]
ref $self->{"sort_code"} eq "ARRAY"
$self->{"sort_code"}[$this_sort_column]
Truth table33%1/3
A and B
A= ref $self->{"sort_code"} eq "ARRAY"B= $self->{"sort_code"}[$this_sort_column]
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $this_sort_method = $self->{sort_code}->[$this_sort_column]; | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 7 | my $this_toggle = $this_sort_column =~ s/^\-(\d+)$/$1/; | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 7 | ▶ | unless($this_sort_method) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | $this_sort_method = 'aa'; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 7 | ▶ | for(my $i=0;$i<=$self->{rows};$i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 7 | ▶ | if($self->{results}->[$i]->[$this_sort_column] =~ /[^0-9.\-+ ]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 6 | last; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } elsif($self->{results}->[$i]->[$this_sort_column] =~ /^[0-9.\-+]+$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | ▶ | next if($self->{results}->[$i]->[$this_sort_column] =~ /^\.+$/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | $this_sort_method = 'na'; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 7 | ▶ | if($total_sorts == $this_sort) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 5 | ▶ | if($this_toggle && $this_sort_method =~ /^.a$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$this_toggle and $this_sort_method =~ /^.a$/
MC/DC50%1/2
$this_toggle and $this_sort_method =~ /^.a$/
$this_toggle
$this_sort_method =~ /^.a$/
Truth table66%2/3
A and B
A= $this_toggleB= $this_sort_method =~ /^.a$/
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 4 | $this_sort_method =~ s/^(.)a$/$1d/i; | |||||||||||||||||||||||||||||||||||||||||
| 121 | ▶ | } elsif($this_toggle && $this_sort_method =~ /^.d$/) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$this_toggle and $this_sort_method =~ /^.d$/
MC/DC0%0/2
$this_toggle and $this_sort_method =~ /^.d$/
$this_toggle
$this_sort_method =~ /^.d$/
Truth table33%1/3
A and B
A= $this_toggleB= $this_sort_method =~ /^.d$/
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $this_sort_method =~ s/^(.)d$/$1a/i; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | # I just change stuff of type link to stuff of type regex, with the regex below | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 7 | ▶ | if ($this_sort_method =~ s/^l(.)$/r$1/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | die "need regex for sort_method on column $this_sort_column" unless(exists $self->{sort_method_regex}->{$this_sort_column}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $self->{sort_method_regex}->{$this_sort_column} = qr@<a\s+href[^>]+?>(.+?)</a>@i; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 7 | my $symbol; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 7 | my $special_sort_method = 0; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 7 | ▶ | if($this_sort_method =~ /^a.$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 6 | $symbol = 'cmp'; | |||||||||||||||||||||||||||||||||||||||||
| 136 | } elsif ($this_sort_method =~ /^n.$/i) { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | $symbol = '<=>'; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } elsif ($this_sort_method =~ /^t.$/i) { | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $special_sort_method = 1; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } elsif ($this_sort_method =~ /^r.$/i) { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | die "need regex for sort_method on column $this_sort_column" unless($self->{sort_method_regex}->{$this_sort_column}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $symbol = $self->{sort_method_symbol}->{$this_sort_column} || 'cmp'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'sort_method_symbol'}{$this_sort_column} || 'cmp'
MC/DC0%0/1
$self->{'sort_method_symbol'}{$this_sort_column} || 'cmp'
$self->{'sort_method_symbol'}{$this_sort_column}
Truth table0%0/2
A
A= $self->{'sort_method_symbol'}{$this_sort_column}
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $self->{sort_code_text} .= <<SORT_METHOD; | |||||||||||||||||||||||||||||||||||||||||
| 144 | my (\$_a) = \$self->{results}->[\$a]->[$this_sort_column] =~ /$self->{sort_method_regex}->{$this_sort_column}/; | ||||||||||||||||||||||||||||||||||||||||||
| 145 | my (\$_b) = \$self->{results}->[\$b]->[$this_sort_column] =~ /$self->{sort_method_regex}->{$this_sort_column}/; | ||||||||||||||||||||||||||||||||||||||||||
| 146 | SORT_METHOD | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if($self->{sort_code}->[$this_sort_column] =~ /^.d$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $self->{sort_code_text} = "{\n $self->{sort_code_text}\n \$_b $symbol \$_a\n}"; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $self->{sort_code_text} = "{\n $self->{sort_code_text}\n \$_a $symbol \$_b\n}"; | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $special_sort_method = 1; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | die "unknown sort method $this_sort_method"; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 7 | ▶ | if(!$special_sort_method && $this_sort_method =~ /^.a$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
not $special_sort_method and $this_sort_method =~ /^.a$/i
MC/DC50%1/2
not $special_sort_method and $this_sort_method =~ /^.a$/i
not $special_sort_method
$this_sort_method =~ /^.a$/i
Truth table66%2/3
not(A) and B
A= not $special_sort_methodB= $this_sort_method =~ /^.a$/i
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 3 | $self->{sort_code_text} .= ' $self->{results}->[$a]->[' . "$this_sort_column" .'] ' . "$symbol" . ' $self->{results}->[$b]->[' . "$this_sort_column" . "] ||\n"; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } elsif ($this_sort_method =~ /^.d$/i) { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 | $self->{sort_code_text} .= ' $self->{results}->[$b]->[' . "$this_sort_column" .'] ' . "$symbol" . ' $self->{results}->[$a]->[' . "$this_sort_column" . "] ||\n"; | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | # sadly, this line is to unbug vi { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | $self->{sort_code_text} =~ s/\s*\|\|\s*$/\n\}/; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | ▶ | sub make_sort_code_ref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_sort_code_ref: called CC=4 SCAR=15.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 5 | ▶ | return if($self->{sort_code_ref} && ref $self->{sort_code_ref} eq 'CODE'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"sort_code_ref"} and ref $self->{"sort_code_ref"} eq "CODE"
MC/DC0%0/2
$self->{"sort_code_ref"} and ref $self->{"sort_code_ref"} eq "CODE"
$self->{"sort_code_ref"}
ref $self->{"sort_code_ref"} eq "CODE"
Truth table33%1/3
A and B
A= $self->{"sort_code_ref"}B= ref $self->{"sort_code_ref"} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 5 | $self->make_sort_code_text; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 5 | $self->{sort_code_ref} = eval $self->{sort_code_text}; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 5 | ▶ | if($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | die "$self->{sort_code_text}\ndid not lead to a valid CODE ref"; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | __END__ | ||||||||||||||||||||||||||||||||||||||||||