in reply to Garbage Collection on Hash delete
If you are following good programming guidelines, then you don't even have to worry about this. What do I define as 'good programming guidelines' in regards to this case? Put simply: the use of subroutines. If you split up your scripts into several subroutines as any well-behaving programmer would do, then your structures will not exist for long, as perl's garbage collecting schemes will take care of everything on its own.
Just minimize/vaporize your use of global package variables and you'll be happier than an ape with a bunch of bananas (I was thinking along the lines of 'more fun than a barrel of monkeys', with 'happy' instead of 'fun').
Update: As bart mentions in his reply, the actual area to focus on is scope rather than subroutines. This is what I was implying by the use of well-structured scripts with well-scripted subroutines. Subroutines themselves contain within themselves a scope, so that once execution of a subroutine is complete, the scope is exited as well. IMO, subroutines are simply the best way to enforce scope, as opposed to using many { my $a = "hi"; } type blocks. As an additional comment, packages themselves are another great way of implementing scoping. If you've got a lot of code you reuse all the time, create a package out of it. A thank you goes out to bart for further clarifying.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Garbage Collection on Hash delete
by bart (Canon) on Jan 12, 2003 at 12:49 UTC |