Skip to content

Instantly share code, notes, and snippets.

@kfly8
Created June 22, 2019 19:22
Show Gist options
  • Save kfly8/123fb49e14ea767ddc069ca00520575f to your computer and use it in GitHub Desktop.
Save kfly8/123fb49e14ea767ddc069ca00520575f to your computer and use it in GitHub Desktop.
use Benchmark qw(cmpthese);
sub hello { return 'HELLO' }
sub world { return 'WORLD' }
sub hello2 { return 'HELLO' }
*{"hello"} = bless \&hello, __PACKAGE__;
hello();
my $hello = \&hello;
$hello->world;
# almost same
#cmpthese -1, {
# hello => sub { hello() },
# hello2 => sub { hello2() },
# hello_coderef => sub { $hello->() },
#};
use Devel::Peek;
Dump $hello;
warn ref $hello; # main
warn ref \&hello; # main
warn ref \&hello2; # CODE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment