Caller::Easy - less stress to remind returned list from CORE::caller()
use Caller::Easy; # Module name is temporal # the way up to now sub foo { my $subname = (caller(0))[3]; } # with OO sub foo { my $subname = Caller::Easy->new(0)->subroutine(); } # like a function imported sub foo { my $subname = caller(0)->subroutine(); }
All the above will return 'main::foo'
Now you can choise the way you much prefer
Caller::Easy is the easiest way for using functions of CORE::caller()
CORE::caller()
it produces the easier way to get some info from caller() with no having to care about namespace.
caller()
You can set no argument then it returns the object reference in scalar context.
In list context, you can get just only ( $package, $filename, $line ).
if you set depth(level) like new(1), you can get more info from caller ( $package, $filename, $line, $subroutine, $hasargs, $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash ) directly with same term for CORE::caller()
new(1)
To be strictly, you can set depth parameter like new( depth => 1 ) but we can forget it, just set the natural number you want to set.
depth
new( depth => 1 )
It is implemented to be alias of new() but it doesn't matter.
new()
this method is imported to your packages automatically when you use Caller::Easy;
use Caller::Easy;
So you can use much freely this method like if there is no module imported.
You can get package name instead of (caller(n))[0]
(caller(n))[0]
You can get file name instead of (caller(n))[1]
(caller(n))[1]
You can get the line called instead of (caller(n))[2]
(caller(n))[2]
You can get the name of subroutine instead of (caller(n))[3]
(caller(n))[3]
Please read CORE::caller
Don't ask me
You can get the arguments of targeted subroutine instead of @DB::args
@DB::args
This method is the unique point of this module.
You can get what you set.
I made this module in a few days with Moose because it's the easiest way. It will be too heavy for some environments.
To abolish Moose is a TODO if this module will be popular.
I don't know well about CORE::caller!
Why I have written this module is Just only I can't remember what I wanna get with something number from caller() without some reference.
So some of tests may not be appropriate.
I have to find the name that deserve it.
I know well that my English is awful.
If you are confused with this module, Please read this carefully.
One of better implements for using something like this module.
The reason why I reinvent the wheel is that this module has no github repository.
The newest implement for using something like this module.
It has github repository but usage is limited.
Copyright (C) Yuki Yoshida.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Yuki Yoshida <worthmine@gmail.com>
To install Caller::Easy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Caller::Easy
CPAN shell
perl -MCPAN -e shell install Caller::Easy
For more information on module installation, please visit the detailed CPAN module installation guide.