
Devel::refcount provides a single function which obtains the reference count of the object being pointed to by the passed reference value.
internally, perl maintains a count of the number of 'things' referring to each variable, as a means of providing automatic memory management. every time a reference is made to a scalar value, for example, the reference count is incremented; every time that reference is lost (eg. when a lexical variable goes out of scope) then the reference count is decremented.