develooper Front page | perl.perl5.porters | Postings from March 2013

Re: Perlfunc for each(), keys(), values() has been changed

Thread Previous | Thread Next
Brad Baxter
March 29, 2013 17:16
Re: Perlfunc for each(), keys(), values() has been changed
Message ID:
On Fri, Mar 29, 2013 at 1:06 PM, Aristotle Pagaltzis <>wrote:

> But the specific behaviour now is really quite irrelevant. (Even more so
> is defending why it got to be that way; IMO that merits mention only as
> gory details for the curious.) The point of interest to a programmer
> consulting the docs is guidance on what to *do*: how to write correct
> code; not background on what Perl does and why. IMO that is the emphasis
> with which it should be written.
> So how about this? Or something along these lines.

In the spirit of guidance on what to do, I think including the examples
below to help understand "the entry most recently returned from C<each> or
C<keys>" (particularly keys) would be helpful.

On 29 March 2013 15:19, David Golden <> wrote:
> On Fri, Mar 29, 2013 at 7:39 AM, demerphq <> wrote:
> I don't understand what you mean by "most recent key returned by each
> or keys".  What is the most recent key returned by keys()?  Are you
> trying to say you can delete during each() without changing the order
> of subsequent keys/values returned by each()?

Well it means that

keys %hash; #reset each iterator
while (my $key= each %hash) {
  delete $hash{$key};


foreach my $key (keys %hash) {
  delete $hash{$key};

will never change the iteration order.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About