| 1 | package Caller::Hide; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use version 0.77; our $VERSION = version->declare('v0.0.1'); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use parent 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | our @EXPORT_OK = qw[ hide_package reveal_package ]; | |||||||||||||||||||||||||||
| 9 | 2 | our %EXPORT_TAGS = (ALL => \@EXPORT_OK); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | my %hidden; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | { # adapted from Hook::LexWrap | ||||||||||||||||||||||||||||
| 14 | 2 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 74 | ▶ | *CORE::GLOBAL::caller = sub (;$) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||
| 16 | 74 | ▶ | my ($height) = ($_[0] || 0); | ||||||||||||||||||||||||||
|
Condition100%2/2
$_[0] || 0
MC/DC100%1/1
$_[0] || 0
$_[0]
Truth table100%2/2
A
A= $_[0]
| |||||||||||||||||||||||||||||
| 17 | 74 | my $i = 1; | |||||||||||||||||||||||||||
| 18 | 74 | my $name_cache; | |||||||||||||||||||||||||||
| 19 | 74 | while (1) { | |||||||||||||||||||||||||||
| 20 | my @caller | ||||||||||||||||||||||||||||
| 21 | = CORE::caller() eq 'DB' | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | ? do { package DB; CORE::caller($i++) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | : CORE::caller($i++); | ||||||||||||||||||||||||||||
| 24 | 319 | ▶ | return if not @caller; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 302 | ▶ | $caller[3] = $name_cache if $name_cache; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 302 | ▶ | $name_cache = $hidden{ $caller[0] } ? $caller[3] : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 302 | ▶ | next if $name_cache || $height-- != 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$name_cache or $height-- != 0
MC/DC100%2/2
$name_cache or $height-- != 0
$name_cache
$height-- != 0
Truth table100%3/3
A or B
A= $name_cacheB= $height-- != 0
| |||||||||||||||||||||||||||||
| 28 | 57 | ▶ | return wantarray ? @_ ? @caller : @caller[ 0 .. 2 ] : $caller[0]; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | 2 | }; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 6 | ▶ | sub hide_package { | ||||||||||||||||||||||||||
|
Subroutine
hide_package: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 6 | my ($package) = @_; | |||||||||||||||||||||||||||
| 35 | 6 | $hidden{$package} = 1; | |||||||||||||||||||||||||||
| 36 | 6 | return; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 6 | ▶ | sub reveal_package { | ||||||||||||||||||||||||||
|
Subroutine
reveal_package: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 6 | my ($package) = @_; | |||||||||||||||||||||||||||
| 41 | 6 | ▶ | Carp::carp "$package not hidden" if not $hidden{$package}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 6 | delete $hidden{$package}; | |||||||||||||||||||||||||||
| 44 | 6 | return; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 2 | 1; | |||||||||||||||||||||||||||
| 48 | __END__ | ||||||||||||||||||||||||||||