| 1 | package List::StackBy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use 5.020000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | stack_by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ) ] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | stack_by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | sub stack_by(&@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stack_by: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | my $prev_key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | for (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 10 | my $cur_key = $code->( $_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 10 | ▶ | if (not(ref $prev_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
ref $prev_key and defined $cur_key and defined $$prev_key and $cur_key eq $$prev_key
ref $prev_key and defined $cur_key and defined $$prev_key
ref $prev_key and defined $cur_key
MC/DC50%2/4
ref $prev_key and defined $cur_key and defined $$prev_key and $cur_key eq $$prev_key
ref $prev_key
defined $cur_key
defined $$prev_key
$cur_key eq $$prev_key
Truth table60%3/5
A and B and C and D
A= ref $prev_keyB= defined $cur_keyC= defined $$prev_keyD= $cur_key eq $$prev_key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | or not(defined $cur_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | or not(defined $$prev_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | or not($cur_key eq $$prev_key)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 7 | push @result, []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 10 | push @{ $result[-1] }, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 10 | $prev_key = \$cur_key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | return @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||