in reply to array looping with foreach

You can install Array::Each::Override and override each. This will allow you to obtain both the index and the value of each array element.

• another intruder with the mooring in the heart of the Perl

  • Comment on Re: array looping with foreach (try Array::Each::Override)

Replies are listed 'Best First'.
Re^2: array looping with foreach (try Array::Each::Override)
by ruzam (Curate) on Jan 19, 2008 at 05:42 UTC
    I'm a little confused by the point of Array::Each::Override

    Being able to override each to use it on an array is nice and surely useful at times. But at the same time you're hurting the built in each performance on hashes (which you're likely to be doing more of in your code to start with). The values override adds nothing to working with arrays, and again hurts the built in values performance on hashes. The keys override doesn't appear to add much in the way of usefulness either again with the built in keys performance hit.

    But I'm running off topic...