« lib/Perlmazing/Engine/Exporter.pm
↑ Summary
lib/Perlmazing/Perlmazing/Precompile/sort_by_value.pm »
| 1 | 30 | ▶ | BEGIN { | ||||||||||||
|
Subroutine
BEGIN: called CC=5 SCAR=20.9
| |||||||||||||||
| 2 | 30 | ▶ | no warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 30 | ▶ | eval 'sub test_prototype (+) { 1 }; test_prototype(1);'; | ||||||||||||
|
Subroutine
test_prototype: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 30 | undef *test_prototype; | |||||||||||||
| 5 | 30 | ▶ | if (my $e = $@) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 6 | 0 | ▶ | if ($e =~ /Malformed prototype/) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 7 | 0 | eval 'sub main (;\[@%]) { main_code(@_) }'; | |||||||||||||
| 8 | 0 | ▶ | die $@ if $@; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 9 | } else { | ||||||||||||||
| 10 | 0 | die $e; | |||||||||||||
| 11 | } | ||||||||||||||
| 12 | } else { | ||||||||||||||
| 13 | 0 | ▶ | eval 'sub main (+) { main_code(@_) }'; | ||||||||||||
|
Subroutine
main: not called CC=1 SCAR=1.2
| |||||||||||||||
| 14 | 30 | ▶ | die $@ if $@; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 15 | } | ||||||||||||||
| 16 | } | ||||||||||||||
| 17 | |||||||||||||||
| 18 | 30 | ▶ | use Perlmazing qw(isa_hash void_context isa_array numeric list_context scalar_context); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 19 | |||||||||||||||
| 20 | 0 | ▶ | sub main_code { | ||||||||||||
|
Subroutine
main_code: not called CC=8 SCAR=42.8
| |||||||||||||||
| 21 | 0 | my $list = $_[0]; | |||||||||||||
| 22 | 0 | ▶ | if (isa_hash $list) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 23 | 0 | ▶ | if (void_context()) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 24 | 0 | my @call = caller(0); | |||||||||||||
| 25 | 0 | warn "Useless call to sort_by_key for a hash in void context (keys won't remain sorted in a hash) at $call[1] line $call[2]\n"; | |||||||||||||
| 26 | 0 | return; | |||||||||||||
| 27 | } | ||||||||||||||
| 28 | 0 | $list = [%$list]; | |||||||||||||
| 29 | } elsif (not isa_array $list) { | ||||||||||||||
| 30 | 0 | return $_[0]; | |||||||||||||
| 31 | } | ||||||||||||||
| 32 | 0 | my @temp; | |||||||||||||
| 33 | 0 | ▶ | for (my $i = 0; $i < @$list; $i += 2) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 34 | 0 | push @temp, {key => $list->[$i], value => $list->[$i + 1]}; | |||||||||||||
| 35 | } | ||||||||||||||
| 36 | 0 | @temp = map {$_->{key}, $_->{value}} sort { | |||||||||||||
| 37 | 0 | ▶ | if (lc $a->{key} eq lc $b->{key}) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 38 | 0 | numeric ($a->{key}, $b->{key}); | |||||||||||||
| 39 | } else { | ||||||||||||||
| 40 | 0 | numeric (lc $a->{key}, lc $b->{key}); | |||||||||||||
| 41 | } | ||||||||||||||
| 42 | } @temp; | ||||||||||||||
| 43 | 0 | ▶ | if (list_context()) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 44 | 0 | @temp; | |||||||||||||
| 45 | } elsif (scalar_context()) { | ||||||||||||||
| 46 | 0 | \@temp; | |||||||||||||
| 47 | } else { | ||||||||||||||
| 48 | 0 | @{$_[0]} = @temp; | |||||||||||||
| 49 | } | ||||||||||||||
| 50 | } | ||||||||||||||
| 51 | |||||||||||||||
| 52 | 1; | ||||||||||||||