"...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.
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link
or How to display code and escape characters
are good places to start.