By "bug", I presume you mean "bug in your code". The "exiting from the middle of an each-loop" has been discussed here before, and the behavior of Perl is as documented.
Sorry I gave the impression (probably through my choice of title) that I thought this was a bug in Perl. I did mean a bug in the snippet I presented. Perl's behavior is, as you say, amply documented.
| [reply] |
And for small hashes, that is fine. It's less so for a general purpose function in a module - it might get passed in a large hash, possibly even one that's tied to storage on disk.
| [reply] |
| [reply] |
| [reply] |
Well, I'd argue that any program for which the difference between a keys-based walk and an each-based walk is significant shouldn't be using hashes that large, not with the arrival of things like DBD::SQLite or other cheap databases.
Yes, it mattered when Perl was running on 10Mhz 1Megabyte machines, and databases were tough, so a DBM hash was a cool thing. Those are long gone. {grin}
| [reply] |
Oh sure. But you don't always live in an ideal world. Sometimes, the data format is given, and Perl (and the programmer) just has to adapt. That's what Perl is supposed to be good at.
| [reply] |