How can I free an array or hash so my program shrinks?

You can't. Memory the system once allocates to a problem will never be returned to the system. That's why long-running programs sometimes re-exec themselves.

However, judicious use of my on your variables will help make sure that they go out of scope so that Perl can free up their storage for use in other parts of your program. (NB: my variables also execute about 10% faster than globals.) A global variable, of course, never goes out of scope, so you can't get its space automatically reclaimed, although undefing and/or deleteing it will achieve the same effect. In general, memory allocation and de-allocation isn't something you can or should be worrying about much in Perl, but even this capability (preallocation of data types) is in the works.