Last active
August 29, 2015 14:24
-
-
Save akimacho/cc076786f24e0c5865b4 to your computer and use it in GitHub Desktop.
standard function "caller"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use utf8; | |
use Piyo; | |
use DDP {deparse => 1,}; | |
warn "I'm " . __PACKAGE__ . "\n"; | |
my @context = caller; | |
p @context; | |
my $p = Piyo->new; | |
__END__ | |
I'm main | |
[] | |
I'm Piyo | |
I'm Hoge | |
[ | |
[0] "Piyo", | |
[1] "Piyo.pm", | |
[2] 11 | |
] | |
[ | |
[0] "main", | |
[1] "caller.pl", | |
[2] 10 | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Hoge; | |
use strict; | |
use warnings; | |
use utf8; | |
use DDP {deparse => 1,}; | |
sub new { | |
my ($class, %args) = @_; | |
warn "I'm " . __PACKAGE__ . "\n"; | |
my @context = caller; | |
p @context; | |
bless \%args, $class; | |
} | |
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Piyo; | |
use strict; | |
use warnings; | |
use utf8; | |
use Hoge; | |
use DDP {deparse => 1,}; | |
sub new { | |
my ($class, %args) = @_; | |
warn "I'm " . __PACKAGE__ . "\n"; | |
$args{Hoge} = Hoge->new; | |
my @context = caller; | |
p @context; | |
bless \%args, $class; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment