The point wasn't about indexes being numbers or not...
Yes, I understood that you had missed this essential point. That was why I tried to bring it to your attention.
it was that modifying an array while iterating over it is dangerous
As I tried to suggest in my original message, it isn't dangerous. Sorry this wasn't clear to you.
I understand that you fear this construction because you don't understand it, and that you have a faulty mental model of the way foreach loops are processed, which leads you to an incorrect expectation of what they will do when the underlying array is modified. However, this fear is only your private emotion. It is real, but it does not extend outside of yourself. In particular, you cannot conclude from the fact of your fear that the practice is actually "dangerous".
-
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>
<u> <ul>
-
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
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|