NAME

Devel::Refcount - obtain the REFCNT value of a referent

SYNOPSIS

use Devel::Refcount qw( refcount );

my $anon = [];

print "Anon ARRAY $anon has " . refcount($anon) . " reference\n";

my $otherref = $anon;

print "Anon ARRAY $anon now has " . refcount($anon) . " references\n";

DESCRIPTION

This module provides a single function which obtains the reference count of the object being pointed to by the passed reference value.

This differs from Devel::Peek::SvREFCNT in that SvREFCNT() gives the reference count of the SV object itself that it is passed, whereas refcount() gives the count of the object being pointed to. This allows it to give the count of any referent (i.e. ARRAY, HASH, CODE, GLOB and Regex types) as well.

FUNCTIONS

$count = Refcount($ref)

Returns the reference count of the object being pointed to by $ref.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>