If you'd enabled strict you'd have gotten a complaint that you can't use the string "group1" as a HASH ref. The problem is that your line initializing $test_hash{ $group } = $group prevents perl from autovivifying that as a hashref later when you try and use it as such in the for loop. What's happening is that you've got a symbolic reference to the hash %{ $test_hash{ $group } } (i.e. %main::group1) and that's persisting between the two calls (since it's not a lexical).
Either don't initialize $test_hash{ $group }, or explicitly initialize it with a hashref $test_hash{ $group } = {}.
In reply to Re: my Hash Persisting?
by Fletch
in thread my Hash Persisting?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |