| 1 | #============================================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Module: Term::CLI::Util | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # Description: Utility functions for Term::CLI | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # Author: Steven Bakker (SBAKKER), <cpanman@monkey-mind.net> | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # Created: 21/01/2022 | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # Copyright (c) 2022 Steven Bakker | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # This module is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # it under the same terms as Perl itself. See "perldoc perlartistic." | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # This software is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||||||||||||||||
| 19 | #============================================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | package Term::CLI::Util 0.061001; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 13 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 13 | ▶ | use parent qw( Exporter ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 13 | ▶ | use List::Util qw( first ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 13 | ▶ | use Getopt::Long 2.38 qw( GetOptionsFromArray ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 13 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | # When "pass_through" is enabled, Getopt::Long >= 2.51 will leave a | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # "--" in the argument list, but older versions won't. | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 13 | my $HAVE_OLD_GETOPT = $Getopt::Long::VERSION < 2.51; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 13 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 13 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||
| 37 | get_options_from_array | ||||||||||||||||||||||||||||||||||||||||||
| 38 | is_prefix_str | ||||||||||||||||||||||||||||||||||||||||||
| 39 | find_obj_name_matches | ||||||||||||||||||||||||||||||||||||||||||
| 40 | find_text_matches | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 13 | our @EXPORT = (); | |||||||||||||||||||||||||||||||||||||||||
| 43 | 13 | our %EXPORT_TAGS = ( all => \@EXPORT_OK ); | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 202 | ▶ | sub is_prefix_str { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_prefix_str: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 202 | my ($substr, $str) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 202 | return rindex( $str, $substr, 0 ) == 0; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 48 | ▶ | sub get_options_from_array { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_options_from_array: called CC=11 SCAR=24.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 48 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 53 | my ($arguments, $result, $opt_specs, $pass_through) = | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 48 | @args{qw(args result spec pass_through)}; | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 48 | ▶ | $result //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table50%1/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 48 | my $double_dash; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 48 | ▶ | Getopt::Long::Configure( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | qw(bundling require_order), | ||||||||||||||||||||||||||||||||||||||||||
| 62 | ($pass_through ? '' : 'no_') . 'pass_through' | ||||||||||||||||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 48 | ▶ | if ( $pass_through && $HAVE_OLD_GETOPT ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pass_through and $HAVE_OLD_GETOPT
MC/DC0%0/2
$pass_through and $HAVE_OLD_GETOPT
$pass_through
$HAVE_OLD_GETOPT
Truth table66%2/3
A and B
A= $pass_throughB= $HAVE_OLD_GETOPT
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $double_dash = first { $_ eq '--' } @{$arguments}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 48 | ▶ | $double_dash //= q{}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$double_dash //= ""
MC/DC0%0/1
$double_dash //= ""
$double_dash
Truth table50%1/2
A
A= $double_dash
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 48 | my $error = q{}; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 48 | my $ok = do { | |||||||||||||||||||||||||||||||||||||||||
| 73 | 48 | ▶ | local ( $SIG{__WARN__} ) = sub { chomp( $error = join( q{}, @_ ) ) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 48 | GetOptionsFromArray( $arguments, $result, @{$opt_specs} ); | |||||||||||||||||||||||||||||||||||||||||
| 75 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 48 | ▶ | if ( $pass_through && !$HAVE_OLD_GETOPT ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pass_through and not $HAVE_OLD_GETOPT
MC/DC50%1/2
$pass_through and not $HAVE_OLD_GETOPT
$pass_through
not $HAVE_OLD_GETOPT
Truth table66%2/3
A and not(B)
A= $pass_throughB= not $HAVE_OLD_GETOPT
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 31 | ▶ | if ( @{$arguments} && $arguments->[0] eq '--' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@{$arguments;} and $arguments->[0] eq "--"
MC/DC100%2/2
@{$arguments;} and $arguments->[0] eq "--"
@{$arguments;}
$arguments->[0] eq "--"
Truth table100%3/3
A and B
A= @{$arguments;}B= $arguments->[0] eq "--"
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | $double_dash = shift @{$arguments}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 48 | ▶ | success => $ok, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | error_msg => $error, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | $pass_through ? ( double_dash => $double_dash ne q{} ) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 87 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 119 | ▶ | sub find_obj_name_matches { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_obj_name_matches: called CC=18 SCAR=28.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 119 | my ( $text, $list, %opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 119 | ▶ | return if !$list || @$list == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $list or @$list == 0
MC/DC100%2/2
not $list or @$list == 0
not $list
@$list == 0
Truth table100%3/3
not(A) or B
A= not $listB= @$list == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 113 | my $exact = $opt{exact}; | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 113 | ▶ | if ( @$list <= 10 || ( !$exact && @$list <= 45 ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@$list <= 10 or not $exact and @$list <= 45
not $exact and @$list <= 45
MC/DC100%3/3
@$list <= 10 or not $exact and @$list <= 45
@$list <= 10
not $exact
@$list <= 45
Truth table100%4/4
A or not(B) and C
A= @$list <= 10B= not $exactC= @$list <= 45
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 67 | my @found; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 67 | foreach (@{$list}) { | |||||||||||||||||||||||||||||||||||||||||
| 100 | 160 | my $n = $_->name; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 160 | ▶ | next if $n lt $text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 92 | ▶ | if (rindex( $n, $text, 0 ) == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 83 | push @found, $_; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 83 | ▶ | return @found if $exact && $n eq $text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$exact and $n eq $text
MC/DC100%2/2
$exact and $n eq $text
$exact
$n eq $text
Truth table100%3/3
A and B
A= $exactB= $n eq $text
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 30 | next; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 9 | last; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 14 | return @found; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 46 | my ( $lo, $hi ) = ( 0, $#{$list} ); | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 46 | ▶ | while ($lo < $hi) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 173 | my $mid = int( ($lo + $hi) / 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 173 | my $cmp = $text cmp $list->[$mid]->name; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 173 | ▶ | if ($cmp < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 44 | $hi = $mid; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 44 | next; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 129 | ▶ | if ($cmp > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 92 | ▶ | if ($lo == $hi-1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 8 | $lo++; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 8 | last; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 84 | $lo = $mid; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 84 | next; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 37 | ▶ | return $list->[$mid] if $exact; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | $lo = $hi = $mid; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 10 | my @found; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 10 | foreach (@{$list}[$lo..$#{$list}]) { | |||||||||||||||||||||||||||||||||||||||||
| 136 | 13 | my $n = $_->name; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 13 | ▶ | if (rindex( $n, $text, 0 ) == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 10 | push @found, $_; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 10 | next; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 3 | last; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 10 | return @found; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 42 | ▶ | sub find_text_matches { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_text_matches: called CC=18 SCAR=28.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 42 | my ( $text, $list, %opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 42 | ▶ | return if !$list || @$list == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $list or @$list == 0
MC/DC100%2/2
not $list or @$list == 0
not $list
@$list == 0
Truth table100%3/3
not(A) or B
A= not $listB= @$list == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 38 | my $exact = $opt{exact}; | |||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 38 | ▶ | if ( @$list <= 45 || ( !$exact && @$list <= 215 ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@$list <= 45 or not $exact and @$list <= 215
not $exact and @$list <= 215
MC/DC100%3/3
@$list <= 45 or not $exact and @$list <= 215
@$list <= 45
not $exact
@$list <= 215
Truth table100%4/4
A or not(B) and C
A= @$list <= 45B= not $exactC= @$list <= 215
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 35 | my @found; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 35 | foreach (@{$list}) { | |||||||||||||||||||||||||||||||||||||||||
| 157 | 237 | ▶ | next if $_ lt $text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 56 | ▶ | if (rindex( $_, $text, 0 ) == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 45 | push @found, $_; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 45 | ▶ | return @found if $exact && $_ eq $text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$exact and $_ eq $text
MC/DC100%2/2
$exact and $_ eq $text
$exact
$_ eq $text
Truth table100%3/3
A and B
A= $exactB= $_ eq $text
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 39 | next; | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 11 | last; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 29 | return @found; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | my ( $lo, $hi ) = ( 0, $#{$list} ); | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 3 | ▶ | while ($lo < $hi) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 26 | my $mid = int( ($lo + $hi) / 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 172 | 26 | my $cmp = $text cmp $list->[$mid]; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 26 | ▶ | if ($cmp < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 6 | $hi = $mid; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 6 | next; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 20 | ▶ | if ($cmp > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 17 | ▶ | if ($lo == $hi-1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $lo++; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 17 | $lo = $mid; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 17 | next; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | ▶ | return $list->[$mid] if $exact; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | $lo = $hi = $mid; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | my @found; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | foreach (@{$list}[$lo..$#{$list}]) { | |||||||||||||||||||||||||||||||||||||||||
| 192 | 4 | ▶ | if (rindex( $_, $text, 0 ) == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | push @found, $_; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | return @found; | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | __END__ | ||||||||||||||||||||||||||||||||||||||||||