| 1 | package Devel::ebug::Backend::Plugin::Eval; | ||||||||||
| 2 | |||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 6 | our $VERSION = '0.69'; # VERSION | |||||||||
| 7 | |||||||||||
| 8 | 6 | ▶ | sub register_commands { | ||||||||
|
Subroutine
register_commands: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 9 | return ( | ||||||||||
| 10 | 6 | eval => { sub => \&DB::eval, record => 1 }, | |||||||||
| 11 | yaml => { sub => \&DB::yaml }, | ||||||||||
| 12 | ); | ||||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | |||||||||||
| 16 | package DB; | ||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | # there appears to be something semi-magical about the DB | ||||||||||
| 20 | # namespace that makes this eval only work when it's in it | ||||||||||
| 21 | 2 | ▶ | sub eval { | ||||||||
|
Subroutine
eval: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 22 | 2 | my($req, $context) = @_; | |||||||||
| 23 | 2 | my $eval = $req->{eval}; | |||||||||
| 24 | 2 | ▶ | local $SIG{__WARN__} = sub {}; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 2 | my $v = eval "package $context->{package}; $eval"; ## no critic (BuiltinFunctions::ProhibitStringyEval) | |||||||||
| 27 | 2 | ▶ | if ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 1 | return { eval => $@, exception => 1 }; | |||||||||
| 29 | } else { | ||||||||||
| 30 | 1 | return { eval => $v, exception => 0 }; | |||||||||
| 31 | } | ||||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | sub yaml { | ||||||||
|
Subroutine
yaml: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 35 | 0 | my($req, $context) = @_; | |||||||||
| 36 | 0 | my $eval = $req->{yaml}; | |||||||||
| 37 | 0 | ▶ | local $SIG{__WARN__} = sub {}; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 38 | |||||||||||
| 39 | 0 | my $v = eval "package $context->{package}; use YAML; Dump($eval)"; ## no critic (BuiltinFunctions::ProhibitStringyEval) | |||||||||
| 40 | 0 | ▶ | if ($@) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | return { yaml => $@ }; | |||||||||
| 42 | } else { | ||||||||||
| 43 | 0 | return { yaml => $v }; | |||||||||
| 44 | } | ||||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 6 | 1; | |||||||||
| 48 | |||||||||||
| 49 | __END__ | ||||||||||