Make while(each ...) imply defined($_ = ...)
This came up in ticket #108286.
Quoting Nicholas Clark:
>
> while (<STDIN>)
> while (<*>)
>
> These both always implicitly assigned to $_, always implicitly
> added defined.
>
> while ($_ = <STDIN>)
> while ($a = <STDIN>)
> while ($_ = <*>)
> while ($a = <*>)
> while ($_ = readdir D)
> while ($a = readdir D)
> while ($_ = each %h)
> while ($a = each %h)
>
> The implicit defined added was by commit
4b161ae29769b4a3,
> //depot/maint-5.004/perl@949
>
>
> BUT:
>
> while (readdir D)
>
> The implicit assignment to $_ and defined test were both added in
> *2009* (by commit
114c60ecb1f7)
>
>
> leaving:
>
> while (each %h)
>
>
> So it is the odd one out. And in 2009 we felt comfortable to add
> both the implicit assignment and the defined test in blead for
> readdir, as a bug fix, and have had no reports of it caus-
> ing problems.
[He asked:]
> > > So that's a bug?
[And I responded:]
> > That's what I was trying to ask. :-)
>
> OK, after a quite a bit of deliberation and digging, I'm of the opinion that
>
> 1: yes, it's a bug
...
> So, there's only one use of while(each %...) on CPAN outside of
> debugging or test code, and that's only go the potential to break
> due to assignment now happening to to $_. Compared with 29 matches
> for while\s*\(\s*readdir of which 4 are .pm files. So
>
> 2: I think it's safe to fix it, just like readdir was fixed.
Just *as* readdir was fixed! :-)