On Friday, September 5, 2003, at 11:46 AM, Joe Schaefer wrote:

If $t references a table consisting of 3 entries:

  (foo => 1)
  (foo => 2)
  (foo => 3)

then the docs say that

print "($a => $b)\n" while ($a, $b) = each %$t;

will reproduce the above 3 lines.  But what you actually
get is

  (foo => 1)
  (foo => 1)
  (foo => 1)

Ah, this is why testing is so important! Maybe some TODO tests should be added?


Apache::FakeTable apes Apache::Table much more closely now, including
its C<each> behavior, as well as C<keys>

Neat.


and C<values> (the latter being pretty much useless).

Too bad that Apache/APR::Table doesn't get this right. Maybe we should have a look at how Matt Sergeant implemented CDB_File, since he may have found a way/hack (requires XS) to get each() and values() to DTRT with multivalued keys.

I think that this is the same problem as with C<values>, which given the contents of your table above, this:


print "$_\n" for values %$t;

Would print

1
1
1

Regards,

David

--
David Wheeler                                     AIM: dwTheory
[EMAIL PROTECTED]                              ICQ: 15726394
http://www.kineticode.com/                     Yahoo!: dew7e
                                               Jabber: [EMAIL PROTECTED]
Kineticode. Setting knowledge in motion.[sm]


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to