File Coverage

blib/lib/Caller/Reverse.pm
Criterion Covered Total %
statement 18 18 100.0
branch 4 4 100.0
condition 6 6 100.0
subroutine 6 6 100.0
pod 2 2 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1             package Caller::Reverse;
2              
3 2     2   253726 use 5.006;
  2         8  
4 2     2   18 use strict;
  2         3  
  2         62  
5 2     2   9 use warnings;
  2         34  
  2         227  
6              
7             our $VERSION = '1.01';
8              
9 2     2   15 use base 'Import::Export';
  2         17  
  2         1312  
10              
11             our %EX = (
12             caller_first => [qw/all/],
13             callr => [qw/all/],
14             );
15              
16             sub caller_first {
17 5     5 1 233659 return callr(0, $_[0]);
18             }
19              
20             sub callr {
21 5     5 1 12 my ($n, @caller) = 0;
22 5         49 while (my @l = (caller($n))) {
23 12 100 100     82 unshift @caller, \@l unless
      100        
24             $l[0] =~ m/Caller\:\:Reverse/
25             or
26             !$_[1] && $l[0] =~ m/main/;
27 12         65 $n++;
28             }
29 5 100       38 return wantarray ? @{$caller[$_[0]]} : $caller[$_[0]][0];
  1         13  
30             }
31              
32             =head1 NAME
33              
34             Caller::Reverse - reverse the caller stack.
35              
36             =head1 VERSION
37              
38             Version 1.01
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 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 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<< >>
78              
79             =head1 BUGS
80              
81             Please report any bugs or feature requests to C, or through
82             the web interface at L. 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             You can also look for information at:
92              
93             =over 4
94              
95             =item * RT: CPAN's request tracker (report bugs here)
96              
97             L
98              
99             =item * Search CPAN
100              
101             L
102              
103             =back
104              
105             =head1 ACKNOWLEDGEMENTS
106              
107             =head1 LICENSE AND COPYRIGHT
108              
109             This software is Copyright (c) 2020->2025 by LNATION.
110              
111             This is free software, licensed under:
112              
113             The Artistic License 2.0 (GPL Compatible)
114              
115             =cut
116              
117             1; # End of Caller::Reverse