in reply to Hashes: Deleting elements while iterating

You could use Data::Dumper to dump the contents of your hash instead of printing it yourself:

use Data::Dumper; print Data::Dumper::Dumper(\%index);

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated