Created
February 19, 2015 06:40
-
-
Save niratama/1b4dc2ee4cd7375ac58e to your computer and use it in GitHub Desktop.
呼び出し元のサブルーチンを呼び出す
This file contains hidden or 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use MySub; | |
sub callback { | |
print "in main::callback($_[0])\n"; | |
return "main::callback($_[0])"; | |
} | |
MySub::test_sub('from main'); |
This file contains hidden or 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 MySub; | |
use strict; | |
use warnings; | |
use MySub2; | |
sub callback { | |
print "in MySub::callback($_[0])\n"; | |
} | |
sub test_sub { | |
print "in MySub::test_sub($_[0])\n"; | |
MySub2::test_sub('from MySub'); | |
{ | |
no strict 'refs'; | |
&{(caller)[0].'::callback'}('from MySub')."\n"; | |
} | |
} | |
1; |
This file contains hidden or 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 MySub2; | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use MySub2; | |
sub test_sub { | |
print "in MySub2::test_sub($_[0])\n"; | |
{ | |
no strict 'refs'; | |
&{(caller)[0].'::callback'}('from MySub2')."\n"; | |
} | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment