| 1 | package CGI::Carp::DebugScreen::Dumper; | ||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | our $VERSION = '0.15'; | |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | my $IgnoreOverload; | |||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | sub ignore_overload { shift; $IgnoreOverload = shift; } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
ignore_overload: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||
| 12 | 22 | ▶ | sub dump { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 13 | 22 | my ($pkg, $thingy) = @_; | |||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||
| 15 | 22 | return _dump($thingy); | |||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||
| 18 | 31 | ▶ | sub _dump { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dump: called CC=21 SCAR=31.1
| |||||||||||||||||||||||||||||||||||||||||
| 19 | 31 | my $thingy = shift; | |||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||
| 21 | 31 | my $res = ''; | |||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||
| 23 | 31 | ▶ | require overload if $IgnoreOverload; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||
| 25 | 31 | ▶ | if (!defined $thingy) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | $res .= 'undef'; | |||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||
| 28 | elsif (ref $thingy eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | if (%{ $thingy }) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | $res = qq{<table class="watch" border="1">\n}; | |||||||||||||||||||||||||||||||||||||||
| 31 | 0 | foreach my $key (sort {$a cmp $b} keys %{ $thingy }) { | |||||||||||||||||||||||||||||||||||||||
| 32 | 2 | $res .= q{<tr><th>}._escape($key).q{</th><td>}._dump($thingy->{$key}).qq{</td></tr>\n}; | |||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | $res .= qq{</table>\n}; | |||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||
| 36 | else { | ||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | $res .= '*EMPTY_HASH*'; | |||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||
| 40 | elsif (ref $thingy eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | ▶ | if (@{ $thingy }) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | $res .= join ', ', map { _dump($_) } @{ $thingy }; | |||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||
| 44 | else { | ||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | $res .= '*EMPTY_ARRAY*'; | |||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||
| 48 | elsif (ref $thingy eq 'SCALAR') { | ||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | $res .= _escape(${ $thingy }); | |||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||
| 51 | elsif (ref $thingy eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | $res .= '*CODE*'; | |||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||
| 54 | elsif (ref $thingy eq 'GLOB') { | ||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | $res .= '*GLOB*'; | |||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||
| 57 | elsif (my $name = ref $thingy) { | ||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | my $blessed; | |||||||||||||||||||||||||||||||||||||||
| 59 | 3 | ▶ | my $strval = $IgnoreOverload ? overload::StrVal($thingy) : ''; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 60 | 3 | ▶ | if ($thingy =~ /=HASH/ or $strval =~ /=HASH/) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition66%2/3
$thingy =~ /=HASH/ or $strval =~ /=HASH/
MC/DC50%1/2
$thingy =~ /=HASH/ or $strval =~ /=HASH/
$thingy =~ /=HASH/
$strval =~ /=HASH/
Truth table66%2/3
A or B
A= $thingy =~ /=HASH/B= $strval =~ /=HASH/
| |||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | my %hash = %{ $thingy }; | |||||||||||||||||||||||||||||||||||||||
| 62 | 1 | $blessed = \%hash; | |||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||
| 64 | ▶ | elsif ($thingy =~ /=ARRAY/ or $strval =~ /=ARRAY/) { | |||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$thingy =~ /=ARRAY/ or $strval =~ /=ARRAY/
MC/DC50%1/2
$thingy =~ /=ARRAY/ or $strval =~ /=ARRAY/
$thingy =~ /=ARRAY/
$strval =~ /=ARRAY/
Truth table66%2/3
A or B
A= $thingy =~ /=ARRAY/B= $strval =~ /=ARRAY/
| |||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | my @array = @{ $thingy }; | |||||||||||||||||||||||||||||||||||||||
| 66 | 1 | $blessed = \@array; | |||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||
| 68 | ▶ | elsif ($thingy =~ /=SCALAR/ or $strval =~ /=SCALAR/) { | |||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$thingy =~ /=SCALAR/ or $strval =~ /=SCALAR/
MC/DC0%0/2
$thingy =~ /=SCALAR/ or $strval =~ /=SCALAR/
$thingy =~ /=SCALAR/
$strval =~ /=SCALAR/
Truth table33%1/3
A or B
A= $thingy =~ /=SCALAR/B= $strval =~ /=SCALAR/
| |||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | $blessed = $$thingy; | |||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||
| 71 | elsif ($name eq 'REF') { | ||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $blessed = $$thingy; | |||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||
| 75 | 3 | $res .= qq{<table class="watch" border="1">\n}; | |||||||||||||||||||||||||||||||||||||||
| 76 | 3 | ▶ | $res .= q{<tr><th>}._escape($name).q{ (blessed)</th><td>}.($blessed ? _dump($blessed) : _escape($thingy)).qq{</td></tr>\n}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | $res .= qq{</table>\n}; | |||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||
| 79 | else { | ||||||||||||||||||||||||||||||||||||||||
| 80 | 17 | $res .= _escape($thingy); | |||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||
| 82 | 31 | return $res; | |||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||
| 85 | 23 | ▶ | sub _escape { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_escape: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||
| 86 | 23 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||
| 88 | 23 | ▶ | return 'undef' unless defined $str; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 89 | 23 | ▶ | return '*BINARY*' if $str =~ /[\x00-\x08\x0b\x0c\x0e-\x1f]/; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||
| 91 | 22 | $str =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||
| 92 | 22 | $str =~ s/"/"/g; | |||||||||||||||||||||||||||||||||||||||
| 93 | 22 | $str =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||
| 94 | 22 | $str =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||
| 96 | 22 | ▶ | $str eq '' ? '*BLANK*' : $str; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||
| 101 | __END__ | ||||||||||||||||||||||||||||||||||||||||