Created
January 26, 2012 02:30
-
-
Save kentaro/1680577 to your computer and use it in GitHub Desktop.
Sub::Name
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; | |
package A; | |
use Carp qw(cluck); | |
*name = sub { cluck 'no name' }; | |
package B; | |
use Sub::Name; | |
use Carp qw(cluck); | |
*name = subname name_of_sub => sub { cluck 'has name' }; | |
package main; | |
A::name(); | |
B::name(); | |
__DATA__ | |
$ perl unko.pl | |
no name at unko.pl line 7 | |
A::__ANON__() called at unko.pl line 15 | |
has name at unko.pl line 12 | |
B::name_of_sub() called at unko.pl line 16 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment