Created
June 3, 2015 01:56
-
-
Save oylenshpeegul/4165e7cbff9e546ad26e to your computer and use it in GitHub Desktop.
Compare Devel::Refcount::refcount with Internals::SvREFCNT
This file contains 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 v5.16; | |
use warnings; | |
use Devel::Refcount qw(refcount); | |
my $href = {}; | |
say "BEGIN:" . refcount($href); | |
say "SvREFCNT: ", Internals::SvREFCNT($href); | |
my $href2 = $href; | |
say "VAR:" . refcount($href); | |
say "SvREFCNT: ", Internals::SvREFCNT($href); | |
f1($href); | |
f2($href); | |
my $n1 = f3($href); | |
say "AFTER f3:" . refcount($href); | |
say "SvREFCNT: ", Internals::SvREFCNT($href); | |
my $n2 = f4($href); | |
say "AFTER f4:" . refcount($href); | |
say "SvREFCNT: ", Internals::SvREFCNT($href); | |
sub f1 { | |
say "f1:" . refcount($_[0]); | |
} | |
sub f2 { | |
my $v = shift; | |
say "f2:" . refcount($v); | |
} | |
sub f3 { | |
return { args => \@_ }; | |
} | |
sub f4 { | |
return { args => [@_]}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment