Unreferenced structures are automatically reclaimed by perl. The term for this is "garbage collected". Internally, perl keeps track of how many references an object has. When that count drops to zero, perl reclaims the memory the object used.
The system isn't perfect. For instance, circular references can confuse perl, but for the most part it works well enough.