Skip to content

Instantly share code, notes, and snippets.

@kentaro
Created January 26, 2012 02:30
Show Gist options
  • Save kentaro/1680577 to your computer and use it in GitHub Desktop.
Save kentaro/1680577 to your computer and use it in GitHub Desktop.
Sub::Name
#!/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