| 1 | package App::optex::debug; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | debug - debug module for optex | ||||||||||
| 6 | |||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||
| 8 | |||||||||||
| 9 | optex -Mdebug | ||||||||||
| 10 | |||||||||||
| 11 | =cut | ||||||||||
| 12 | |||||||||||
| 13 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 2 | $Data::Dumper::Sortkeys = 1; | |||||||||
| 17 | |||||||||||
| 18 | 2 | my %switch = ( | |||||||||
| 19 | getopt => \$Getopt::EX::Loader::debug, | ||||||||||
| 20 | debug => \$main::debug, | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | 2 | for my $key (keys %switch) { | |||||||||
| 24 | 4 | ${$switch{$key}} = 1; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 2 | my %dump = ( | |||||||||
| 28 | loader => \$main::rcloader, | ||||||||||
| 29 | ); | ||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | sub dump { | ||||||||
|
Subroutine
dump: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 32 | 0 | $Data::Dumper::Indent = 1; | |||||||||
| 33 | 0 | ▶ | while (my($key, $val) = splice @_, 0, 2) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | ▶ | next unless $val; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | ▶ | if ($key eq 'all') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | @_ = map { ($_ => 1) } keys %dump; | |||||||||
| 37 | 0 | next; | |||||||||
| 38 | } | ||||||||||
| 39 | 0 | ▶ | if (not exists $dump{$key}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | warn __PACKAGE__ . ": Unknown key: $key\n"; | |||||||||
| 41 | 0 | next; | |||||||||
| 42 | } | ||||||||||
| 43 | 0 | local $_ = Dumper $dump{$key}; | |||||||||
| 44 | 0 | $_ = compact($_); | |||||||||
| 45 | 0 | s/^\$VAR1/\$$key/; | |||||||||
| 46 | 0 | print; | |||||||||
| 47 | } | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub compact { | ||||||||
|
Subroutine
compact: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 51 | 0 | local $_ = shift; | |||||||||
| 52 | 0 | my $re_str = qr/'[^']*'/; | |||||||||
| 53 | 0 | my $re_strlist = qr/\[ \s* (?: $re_str , \s*)* $re_str \s* \]/x; | |||||||||
| 54 | 0 | s/($re_strlist)/_compact($1)/ge; | |||||||||
| 55 | 0 | $_; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | sub _compact { | ||||||||
|
Subroutine
_compact: not called CC=1 SCAR=6.9
| |||||||||||
| 59 | 0 | local $_ = shift; | |||||||||
| 60 | 0 | s/ , \s+ ' /, '/xg; | |||||||||
| 61 | 0 | s/ ([\[\{]) \s+ /$1 /xg; | |||||||||
| 62 | 0 | s/ \s+ ([\]\}]) / $1/xg; | |||||||||
| 63 | 0 | $_; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 2 | 1; | |||||||||