http://qs321.pair.com?node_id=328606


in reply to Re: Clean out da hash...
in thread Clean out da hash...

"...is not the greatest of ideas."

Why is it not the greatest of ideas when the docs specifically make it a point to say that it is "always safe to delete the item most recently returned by each()"? The OP's delete example is almost word for word the same as the one provided in the docs that you quoted.

His problem lies elsewhere.

He should be looking at scoping issues. He should also ween himself from passing variables into subs implicitly (as if they were globals) rather than explicitly as parameters to the subs. In this case, it would probably be wise to pass the hash into his delete sub by reference rather than global osmosis. But the act of deleting a hash's elements is so trivial that it hardly warrants its own subroutine.


Dave

Replies are listed 'Best First'.
Re: Re: Re: Clean out da hash...
by GaijinPunch (Pilgrim) on Feb 13, 2004 at 00:19 UTC
    Big thanks to everyone. I finally got the problem figured out. A colleague across the ocean had some time on his hands and looked at it. It was a careless mistake on my side

    Early on in the script (before I changed strategies), I had two counters, to remind me what line I was on. I was assigning the wrong counter as the line number (I was off by one line) and it was pure coincidence that the text file was laid out in a manner where I was snagging a value that represented the sum of both sets of data. Chalk that one up to bad luck and carelessnes.

    I did learn a bit more about hashes though from the thread, so it was definitely not a lost cause. Also learned that if you change the idea of your script, it's not a bad idea to wipe the slate clean.