| 1 | package Sort::Sub::by_dmp; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||
| 4 | 2 | our $DATE = '2019-12-15'; # DATE | |||||||||
| 5 | 2 | our $DIST = 'Sort-Sub-by_dmp'; # DIST | |||||||||
| 6 | 2 | our $VERSION = '0.002'; # VERSION | |||||||||
| 7 | |||||||||||
| 8 | 2 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 2 | ▶ | use Data::Dmp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | sub meta { | ||||||||
|
Subroutine
meta: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 15 | return { | ||||||||||
| 16 | 0 | v => 1, | |||||||||
| 17 | summary => 'Sort data structures by comparing their dump (using Data::Dmp)', | ||||||||||
| 18 | }; | ||||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 1 | ▶ | sub gen_sorter { | ||||||||
|
Subroutine
gen_sorter: called CC=1 SCAR=0.2
Pod
undocumented
| |||||||||||
| 22 | 1 | my ($is_reverse, $is_ci) = @_; | |||||||||
| 23 | |||||||||||
| 24 | 9 | ▶ | sub { | ||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.2
| |||||||||||
| 25 | 2 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | |||||||||||
| 27 | 9 | my $caller = caller(); | |||||||||
| 28 | 0 | ▶ | my $a = @_ ? $_[0] : ${"$caller\::a"}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 0 | ▶ | my $b = @_ ? $_[1] : ${"$caller\::b"}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 9 | my $cmp; | |||||||||
| 32 | |||||||||||
| 33 | # XXX cache | ||||||||||
| 34 | |||||||||||
| 35 | 9 | my $dmp_a = dmp($a); | |||||||||
| 36 | 9 | my $dmp_b = dmp($b); | |||||||||
| 37 | |||||||||||
| 38 | 9 | ▶ | $cmp = $is_ci ? lc($dmp_a) cmp lc($dmp_b) : $dmp_a cmp $dmp_b; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 9 | ▶ | $is_reverse ? -1*$cmp : $cmp; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 1 | }; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 2 | 1; | |||||||||
| 44 | # ABSTRACT: Sort data structures by comparing their dump (using Data::Dmp) | ||||||||||
| 45 | |||||||||||
| 46 | __END__ | ||||||||||