Data-TreeDumper-Utils
view release on metacpan or search on metacpan
lib/Data/TreeDumper/Utils.pm view on Meta::CPAN
| `- CONTEXT = scalar
`- 3
`- main::s3
|- ARGS
| |- 0 = a
| `- 1
| |- 0 = 1
| |- 1 = 2
| `- 2 = 3
|- AT = try_me.pl:29
|- CALLERS_PACKAGE = main
`- CONTEXT = scalar
B<Arguments>
=over 2
=item * $levels_to_dump - the number of level that should be included in the call stack
=back
B<Returns> - the call stack structure
=cut
my $level_to_dump = shift || 1_000_000 ; ## no critic ValuesAndExpressions::ProhibitMagicNumbers
my $current_level = 2 ; # skip this function
$level_to_dump += $current_level ; #
my @stack_dump ;
while ($current_level < $level_to_dump)
{
my ($package, $filename, $line, $subroutine, $has_args, $wantarray,
$evaltext, $is_require, $hints, $bitmask) = eval " package DB ; caller($current_level) ;" ; ## no critic BuiltinFunctions::ProhibitStringyEval
last unless defined $package;
my %stack ;
$stack{$subroutine}{EVAL} = 'yes' if($subroutine eq '(eval)') ;
$stack{$subroutine}{EVAL} = $evaltext if defined $evaltext ;
$stack{$subroutine}{ARGS} = [@DB::args] if($has_args) ; ## no critic Variables::ProhibitPackageVars
$stack{$subroutine}{'REQUIRE-USE'} = 'yes' if $is_require ;
$stack{$subroutine}{CONTEXT} = defined $wantarray ? $wantarray ? 'list' : 'scalar' : 'void' ;
$stack{$subroutine}{CALLERS_PACKAGE} = $package ;
$stack{$subroutine}{AT} = "$filename:$line" ;
unshift @stack_dump, \%stack ;
$current_level++;
}
return(\@stack_dump);
}
#---------------------------------------------------------------------------------
1 ;
=head1 BUGS AND LIMITATIONS
None so far.
=head1 AUTHOR
Nadim ibn hamouda el Khemir
CPAN ID: NH
mailto: nadim@cpan.org
=head1 LICENSE AND COPYRIGHT
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Data::TreeDumper::Utils
You can also look for information at:
=over 4
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/Data-TreeDumper-Utils>
=item * RT: CPAN's request tracker
Please report any bugs or feature requests to L <bug-data-treedumper-utils@rt.cpan.org>.
We will be notified, and then you'll automatically be notified of progress on
your bug as we make changes.
=item * Search CPAN
L<http://search.cpan.org/dist/Data-TreeDumper-Utils>
=back
=head1 SEE ALSO
=cut
( run in 2.172 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )