| 1 | package App::loggrep; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | $App::loggrep::VERSION = '0.002'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: quickly find relevant lines in a log searching by date | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | $App::loggrep::VERSION //= 'dev'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$VERSION //= "dev"
MC/DC0%0/1
$VERSION //= "dev"
$VERSION
Truth table50%1/2
A
A= $VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Tie::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Date::Parse qw(str2time); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 12 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 12 | my ( $class, $log, $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 12 | bless { filename => $log, options => $opt }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 12 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=40 SCAR=44.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 12 | my @errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 12 | my $filename = $self->{filename}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 12 | my @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 12 | my $opt = delete $self->{options}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 12 | ▶ | unless ( defined $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | push @errors, 'no log file provided'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 12 | ▶ | unless ( -e $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | push @errors, "file $filename does not exist"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 12 | ▶ | if ( -d $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | push @errors, "$filename is a directory"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 12 | ▶ | unless ( -r $filename ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | push @errors, "cannot read $filename"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 12 | ▶ | tie @lines, 'Tie::File', $filename or push @errors, $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 12 | $self->{lines} = \@lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 12 | $self->{date} = _make_rx( $opt->date, \@errors, 'date' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 12 | ▶ | my @inclusions = @{ $opt->include // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt->include // []
MC/DC100%1/1
$opt->include // []
$opt->include
Truth table100%2/2
A
A= $opt->include
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 12 | my $insensitive = $opt->case_insensitive; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 12 | $_ = _make_rx( $_, \@errors, 'inclusion', 0, $insensitive ) for @inclusions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | push @inclusions, _make_rx( $_, \@errors, 'inclusion', 1, $insensitive ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 12 | ▶ | for @{ $opt->include_quoted // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opt->include_quoted // []
MC/DC0%0/1
$opt->include_quoted // []
$opt->include_quoted
Truth table50%1/2
A
A= $opt->include_quoted
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->{include} = [ sort { length($a) <=> length($b) } @inclusions ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 12 | ▶ | my @exclusions = @{ $opt->exclude // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt->exclude // []
MC/DC100%1/1
$opt->exclude // []
$opt->exclude
Truth table100%2/2
A
A= $opt->exclude
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 12 | $_ = _make_rx( $_, \@errors, 'exclude', 0, $insensitive ) for @exclusions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | push @exclusions, _make_rx( $_, \@errors, 'exclude', 1, $insensitive ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | ▶ | for @{ $opt->exclude_quoted // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opt->exclude_quoted // []
MC/DC0%0/1
$opt->exclude_quoted // []
$opt->exclude_quoted
Truth table50%1/2
A
A= $opt->exclude_quoted
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $self->{exclude} = [ sort { length($a) <=> length($b) } @exclusions ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 12 | ▶ | my $start = $opt->start // $opt->moment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opt->start // $opt->moment
MC/DC50%1/2
$opt->start // $opt->moment
$opt->start
$opt->moment
Truth table66%2/3
A // B
A= $opt->startB= $opt->moment
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 12 | ▶ | if ($start) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 8 | my $s = str2time $start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 8 | ▶ | push @errors, "cannot parse start time: $start" unless $s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 8 | $self->{start} = $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 12 | ▶ | my $end = $opt->end // $opt->moment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opt->end // $opt->moment
MC/DC50%1/2
$opt->end // $opt->moment
$opt->end
$opt->moment
Truth table66%2/3
A // B
A= $opt->endB= $opt->moment
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 12 | ▶ | if ($end) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 8 | my $s = str2time $end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 8 | ▶ | push @errors, "cannot parse end time: $end" unless $s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | $self->{end} = $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 12 | ▶ | push @errors, 'you are not filtering at all' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
@inclusions or @exclusions or $start or $end
@inclusions or @exclusions or $start
@inclusions or @exclusions
MC/DC0%0/4
@inclusions or @exclusions or $start or $end
@inclusions
@exclusions
$start
$end
Truth table60%3/5
A or B or C or D
A= @inclusionsB= @exclusionsC= $startD= $end
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | unless @inclusions || @exclusions || $start || $end; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 12 | ▶ | $self->{blank} = $opt->blank || defined $opt->separator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opt->blank || defined $opt->separator
MC/DC50%1/2
$opt->blank || defined $opt->separator
$opt->blank
defined $opt->separator
Truth table66%2/3
A || B
A= $opt->blankB= defined $opt->separator
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 12 | $self->{separator} = $opt->separator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 12 | $self->{warn} = $opt->warn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 12 | $self->{die} = $opt->die; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 12 | my ( $before, $after ) = ( 0, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 12 | ▶ | if ( $opt->context || $opt->before || $opt->after ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$opt->context or $opt->before or $opt->after
$opt->context or $opt->before
MC/DC100%3/3
$opt->context or $opt->before or $opt->after
$opt->context
$opt->before
$opt->after
Truth table100%4/4
A or B or C
A= $opt->contextB= $opt->beforeC= $opt->after
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 5 | ▶ | $before = $opt->context // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt->context // 0
MC/DC100%1/1
$opt->context // 0
$opt->context
Truth table100%2/2
A
A= $opt->context
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 5 | ▶ | $before = $opt->before if $opt->before && $opt->before > $before; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opt->before and $opt->before > $before
MC/DC50%1/2
$opt->before and $opt->before > $before
$opt->before
$opt->before > $before
Truth table66%2/3
A and B
A= $opt->beforeB= $opt->before > $before
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | ▶ | $after = $opt->context // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt->context // 0
MC/DC100%1/1
$opt->context // 0
$opt->context
Truth table100%2/2
A
A= $opt->context
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 5 | ▶ | $after = $opt->after if $opt->after && $opt->after > $after; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opt->after and $opt->after > $after
MC/DC50%1/2
$opt->after and $opt->after > $after
$opt->after
$opt->after > $after
Truth table66%2/3
A and B
A= $opt->afterB= $opt->after > $after
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 12 | @$self{qw(before after)} = ( $before, $after ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | { # code options live in their own namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 12 | package __evaled; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 12 | $__evaled::VERSION = '0.002'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 12 | ▶ | for my $m ( @{ $opt->module // [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opt->module // []
MC/DC0%0/1
$opt->module // []
$opt->module
Truth table50%1/2
A
A= $opt->module
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | eval "use $_" for @{ $opt->module // [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$opt->module // []
MC/DC0%0/1
$opt->module // []
$opt->module
Truth table0%0/2
A
A= $opt->module
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | push @errors, "could not load $m"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 24 | ▶ | my $evaler = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 24 | my ( $orig, $option ) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 24 | ▶ | return unless $orig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $majv = int $]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $minv = int( 1000 * ( $] - $majv ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my $code = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | eval "sub { use v$majv.$minv; no strict; no warnings; $orig }"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ( my $e = $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $e =~ s/(.*?) at \(eval \d+\).*/$1/s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | push @errors, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | sprintf 'bad option: --%s; could not evaluate "%s" as perl: %s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | $option, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | $orig, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 12 | ▶ | $self->{code} = $evaler->( $opt->exec, 'exec' ) // sub { shift }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.6
Condition33%1/3
&$evaler($opt->exec, "exec") // sub {
shift();
}
MC/DC0%0/2
&$evaler($opt->exec, "exec") // sub {
shift();
}
&$evaler($opt->exec, "exec")
sub {
shift();
}
Truth table33%1/3
A // B
A= &$evaler($opt->exec, "exec")B= sub {
shift();
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 12 | $self->{time} = $evaler->( $opt->time, 'time' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 12 | return @errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # parse a regular expression parameter, registering any errors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 16 | ▶ | sub _make_rx { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_rx: called CC=5 SCAR=18.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 16 | my ( $rx, $errors, $type, $quote, $insensitive ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 16 | ▶ | unless ($rx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | push @$errors, "inadequate $type pattern"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 16 | ▶ | $rx = quotemeta $rx if $quote; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 16 | ▶ | eval { $rx = $insensitive ? qr/$rx/i : qr/$rx/ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 16 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | push @$errors, "bad $type regex: $rx; error: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 16 | return $rx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 12 | ▶ | sub grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grep: called CC=35 SCAR=36.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | my ( $start, $end, $lines, $include, $exclude, $date, $time ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 12 | @$self{qw(start end lines include exclude date time)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 12 | ▶ | $time //= sub { str2time $1 if shift =~ $date }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.4
Branch: 1 branch
Condition33%1/3
$time //= sub {
str2time($1) if (shift()) =~ /$date/;
}
MC/DC0%0/2
$time //= sub {
str2time($1) if (shift()) =~ /$date/;
}
$time
sub {
str2time($1) if (shift()) =~ /$date/;
}
Truth table33%1/3
A //= B
A= $timeB= sub {
str2time($1) if (shift()) =~ /$date/;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | my ( $blank, $warn, $die, $separator, $before, $after, $code ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 12 | @$self{qw(blank warn die separator before after code)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 12 | ▶ | return unless @$lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 12 | ▶ | my $quiet = !( $warn || $die ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$warn || $die
MC/DC0%0/2
$warn || $die
$warn
$die
Truth table33%1/3
A || B
A= $warnB= $die
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 12 | ▶ | $blank ||= defined $separator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$blank ||= defined $separator
MC/DC50%1/2
$blank ||= defined $separator
$blank
defined $separator
Truth table66%2/3
A ||= B
A= $blankB= defined $separator
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 12 | ▶ | $separator //= "" if $blank; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$separator //= ""
MC/DC0%0/1
$separator //= ""
$separator
Truth table50%1/2
A
A= $separator
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 149 | ▶ | my $gd = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=19.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 149 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 149 | my $t = $time->($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 149 | ▶ | return $t if $t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 94 | ▶ | return if $quiet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $msg = qq(could not find date in "$l"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ($warn) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | print STDERR $msg, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | print STDERR $msg, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 12 | my @include = @$include; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 12 | my @exclude = @$exclude; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 12 | my ( $previous, @bbuf, $abuf ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 55 | ▶ | my $buffer = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 55 | my ( $line, $lineno ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 55 | ▶ | if ($abuf) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | print $code->( $line, $lineno ), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | $previous = $lineno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 4 | $abuf--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | elsif ($before) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 24 | my $pair = [ $line, $lineno ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 24 | push @bbuf, $pair; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 24 | ▶ | shift @bbuf if @bbuf > $before; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 34 | ▶ | my $printline = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 34 | my ( $line, $lineno, $match ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 34 | ▶ | print $separator, "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$blank and $previous and $previous + 1 < $lineno
$blank and $previous
MC/DC100%3/3
$blank and $previous and $previous + 1 < $lineno
$blank
$previous
$previous + 1 < $lineno
Truth table100%4/4
A and B and C
A= $blankB= $previousC= $previous + 1 < $lineno
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | if $blank && $previous && $previous + 1 < $lineno; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 34 | $previous = $lineno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 34 | print $code->( $line, $lineno, $match ), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 12 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 12 | ▶ | my $time_filter = $start || $end; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$start || $end
MC/DC50%1/2
$start || $end
$start
$end
Truth table66%2/3
A || B
A= $startB= $end
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 12 | ▶ | if ($time_filter) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 8 | my ( $t1, $t2, $j ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 8 | for ( 0 .. $#$lines ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 40 | $t1 = $gd->( $lines->[$_] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 40 | $j = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 40 | ▶ | last if $t1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 8 | ▶ | return unless $t1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 8 | for ( reverse $j .. $#$lines ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 24 | $t2 = $gd->( $lines->[$_] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 24 | ▶ | last if $t2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 8 | ▶ | $start = $t1 unless $start; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 8 | ▶ | $end = $t2 unless $end; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 8 | ▶ | return unless $end >= $t1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 8 | ▶ | return unless $start <= $t2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 8 | $i = _get_start( $lines, $start, $t1, $t2, $gd ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 12 | ▶ | if ($before) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 4 | $i -= $before; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 4 | ▶ | $i = 0 if $i < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 12 | ▶ | while ( my $line = $lines->[$i] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 89 | my $lineno = $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 89 | ▶ | if ($time_filter) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 81 | ▶ | my $t = $gd->($line) // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
&$gd($line) // 0
MC/DC100%1/1
&$gd($line) // 0
&$gd($line)
Truth table100%2/2
A
A= &$gd($line)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 81 | ▶ | unless ($t) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 46 | $buffer->( $line, $lineno ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 46 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 35 | ▶ | if ( $t > $end ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 7 | ▶ | if ( $abuf-- ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | print $code->( $line, $lineno ), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 6 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 28 | ▶ | if ( $t < $start ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 5 | $buffer->( $line, $lineno ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 31 | my $good = !@include; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 31 | for (@include) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 4 | ▶ | if ( $line =~ $_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 3 | $good = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 3 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 31 | ▶ | if ($good) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 30 | for (@exclude) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 4 | ▶ | if ( $line =~ $_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 3 | undef $good; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 3 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 31 | ▶ | if ($good) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 27 | $printline->(@$_) for @bbuf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 27 | $printline->( $line, $lineno, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 27 | ▶ | splice @bbuf, 0, scalar @bbuf if $before; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 27 | $abuf = $after; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 4 | $buffer->( $line, $lineno ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # find the log line to begin grepping at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 8 | ▶ | sub _get_start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_start: called CC=14 SCAR=34.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 8 | my ( $lines, $start, $t1, $t2, $gd ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 8 | ▶ | return 0 if $start <= $t1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 5 | my $lim = $#$lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 5 | my ( $s, $e ) = ( [ 0, $t1 ], [ $lim, $t2 ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 5 | my ( $last, $revcount ) = ( -1, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 5 | my $i = _guess( $s, $e, $start ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 9 | ▶ | return $i if $i == $s->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 4 | my $rev = $last == $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 4 | $last = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 4 | ▶ | if ($rev) { # if we find ourselves looping; bail out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $revcount++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ( $revcount > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | --$i if $i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | return $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 4 | $revcount = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 4 | my $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 4 | $t = $gd->( $lines->[$i] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 4 | ▶ | unless ($t) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | $i += $rev ? -1 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | return 0 unless $i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | return $lim if $i > $lim; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | redo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 4 | ▶ | return $i if $t == $start; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | ▶ | if ( $t < $start ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 3 | $s = [ $i, $t ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | $e = [ $i, $t ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 4 | ▶ | if ( $s->[0] == $e->[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | --$i if $i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | return $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 4 | redo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # estimate the next log line to try | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 9 | ▶ | sub _guess { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_guess: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 9 | my ( $s, $e, $start ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 9 | my $delta = $start - $s->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 9 | ▶ | return $s->[0] unless $delta; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 9 | my $diff = $e->[1] - $s->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 9 | my $offset = int( ( $e->[0] - $s->[0] ) * $delta / $diff ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 9 | return $s->[0] + $offset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||