Created
June 22, 2019 19:22
-
-
Save kfly8/123fb49e14ea767ddc069ca00520575f 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
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