|laziness, impatience, and hubris|
Yet More fun With Array Indicesby Elgon (Curate)
|on Sep 14, 2002 at 16:31 UTC||Need Help??|
Elgon has asked for the
wisdom of the Perl Monks concerning the following question:
on a similar point to Limbic~Region's (sounds like a Culture shipname to me) regarding array indices, I have a question on this one: Let's say that I have an array from which I wish to remove a record (in the sense of splice - like a DNA base deletion.) I am using the following code:
Or it could be done this way, I suppose...
Personally I find the for loop somewhat messy and would prefer a tidy foreach instead, however the second way seems equally crufty. Is there simply a far more elegant way of doing this of which I am unaware? Limbic~Region's hypothetical function does do what I want but I was wondering if there was some *magic variable* used by Perl as an iterator in foreach loops somewhat like that found in the each function for use with hashes.
Of the solutions so far, I prefer the first but am very willing to listen to other ideas.
"Rule #17 of Travel: Never try and score dope off Hassidic Jews while under the impression that they are Rastafarians."