blib/lib/Caller/Reverse.pm

filter: Statementstmt 100% 21 / 21 Branchbran 100% 6 / 6 Conditioncond 100% 6 / 6 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 97.7% 43 / 44 CC 6 SCAR 13.2
CC
6
Cov
100%
callr
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
↑ Summary
1 package Caller::Reverse;
2  
3 2 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '0.02';
8  
9 2 ▶use base 'Import::Export';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 our %EX = (
12 caller_first => [qw/all/],
13 callr => [qw/all/],
14 );
15  
16 sub caller_first {
17 5 ▶ return callr(0, $_[0]);
Subroutine caller_first: called CC=1 SCAR=0.0
Pod documented
18 }
19  
20 sub callr {
21 5 ▶ my ($n, @caller) = 0;
Subroutine callr: called CC=6 SCAR=17.9
Pod documented
22 5 ▶ while (my @l = (caller($n))) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@l) = caller $n) 12 5 17
23 12 ▶ unshift @caller, \@l unless
Branch: 1 branch
BranchTrueFalseTotal
unless $l[0] =~ /Caller\:\:Reverse/ or not $_[1] and $l[0] =~ /main/ 4 8 12
Condition100%6/6
$l[0] =~ /Caller\:\:Reverse/ or not $_[1] and $l[0] =~ /main/
l!l&&r!l&&!r
552
not $_[1] and $l[0] =~ /main/
!ll&&!rl&&r
223
MC/DC66%2/3
$l[0] =~ /Caller\:\:Reverse/ or not $_[1] and $l[0] =~ /main/
$l[0] =~ /Caller\:\:Reverse/ not $_[1] $l[0] =~ /main/
Truth table75%3/4
A or not(B) and C
A= $l[0] =~ /Caller\:\:Reverse/B= not $_[1]C= $l[0] =~ /main/
ABCresult
1XX1
0111
00X0
0100
24 $l[0] =~ m/Caller\:\:Reverse/
25 or
26 !$_[1] && $l[0] =~ m/main/;
27 12 $n++;
28 }
29 5 ▶ return wantarray ? @{$caller[$_[0]]} : $caller[$_[0]][0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 4 5
30 }
31  
32 =head1 NAME
33  
34 Caller::Reverse - reverse the caller stack.
35  
36 =head1 VERSION
37  
38 Version 0.02
39  
40 =cut
41  
42 =head1 SYNOPSIS
43  
44 use Caller::Reverse qw/callr caller_first/;
45  
46 my @caller = caller_first();
47  
48 my @callr = callr(2);
49  
50 =head1 DESCRIPTION
51  
52 This is a quick module to return that reverses the caller stack.
53  
54 =cut
55  
56 =head1 EXPORT
57  
58 A list of functions that can be exported.
59  
60 =head2 caller_first
61  
62 Returns the first caller from the stack. In scalar context this will return the package name and in list context you will get the full caller response. See L<https://perldoc.perl.org/functions/caller.html> for more information.
63  
64 my $package = caller_first();
65 my @caller = caller_first();
66  
67 =cut
68  
69 =head2 callr
70  
71 The reverse order of caller.
72  
73 =cut
74  
75 =head1 AUTHOR
76  
77 LNATION, C<< <lnation at cpan.org> >>
78  
79 =head1 BUGS
80  
81 Please report any bugs or feature requests to C<bug-caller-reverse at rt.cpan.org>, or through
82 the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Caller-Reverse>. I will be notified, and then you'll
83 automatically be notified of progress on your bug as I make changes.
84  
85 =head1 SUPPORT
86  
87 You can find documentation for this module with the perldoc command.
88  
89 perldoc Caller::Reverse
90  
91  
92 You can also look for information at:
93  
94 =over 4
95  
96 =item * RT: CPAN's request tracker (report bugs here)
97  
98 L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Caller-Reverse>
99  
100 =item * AnnoCPAN: Annotated CPAN documentation
101  
102 L<http://annocpan.org/dist/Caller-Reverse>
103  
104 =item * CPAN Ratings
105  
106 L<https://cpanratings.perl.org/d/Caller-Reverse>
107  
108 =item * Search CPAN
109  
110 L<https://metacpan.org/release/Caller-Reverse>
111  
112 =back
113  
114 =head1 ACKNOWLEDGEMENTS
115  
116 =head1 LICENSE AND COPYRIGHT
117  
118 This software is Copyright (c) 2020 by LNATION.
119  
120 This is free software, licensed under:
121  
122 The Artistic License 2.0 (GPL Compatible)
123  
124 =cut
125  
126 2 1; # End of Caller::Reverse
↑ Summary