An interesting optimization. Exactly what gets kept, then? I'm guessing it's the probably the array to hold the key references.
/me notes that this will only become a problem if you have lots of different lexicals that hold a lot of data - one after the other - which is probably not a common case, and easily avoided by undef'ing them as demonstrated above
| [reply] |
How could I possibly reuse it? The hash has gone out of scope, there are no external references to the hash or it's elements; I don't see any way of addressing any of it later. | [reply] |
If you run the same sub again, which uses the same lexical again, perl reuse the same memory for it.
| [reply] |
Okay, I understand what you are saying now, but this doesn't seem like a very good thing, especially in an anonymous block (which isn't what I'm using in the actual program but it's still not very smart).
| [reply] |