```{index} single: register (Hash::Util::FieldHash) ``` ```{index} single: Hash::Util::FieldHash::register ``` # register Register an object for garbage collection in the given hashes. ## Synopsis ```perl use Hash::Util::FieldHash qw(id register); my %name; register($obj, \%name); $name{id $obj} = 'Ada'; # deleted when $obj goes away ``` ## What you get back A new reference to the object. Every hash reference after the first argument is marked, so that the object's entry is deleted from it when the object is destroyed; arguments that are not hash references are ignored. Field hashes do this themselves; `register` is for idhashes and ordinary hashes keyed by `id`. A first argument that is not a reference dies with `Attempt to register a non-ref`.