in reply to initializing a hash leaves garbage

{} creates an empty reference to an anonymous hash. To initialiase a hash (not that it's needed), use (). Better still, use strictures (use strict; use warnings;) at the start of all your programs and declare all your variables before use with my %hash; etc.

You'll probably find the Perl data structures cookbook is worth reading


Unless I state otherwise, all my code runs with strict and warnings