On Thu, Sep 01, 2005 at 10:25:24PM +0200, Marcus Holland-Moritz wrote: > I think this is a bug in Perl itself that was introduced with > 5.8.0 and is still present. It can be cut down to this code: > > #!perl -wl > use Tie::Hash; > tie %h, "Tie::StdHash"; > $a = 3.55; > $_ = $a + 0; > $h{a} = $a; > print $h{a}, ", ", @h{qw(a)}; > > __END__ > > [EMAIL PROTECTED] ~ $ perl5.6.2 test.pl > 3.55, 3.55 > > [EMAIL PROTECTED] ~ $ perl5.8.0 test.pl > 3.55, 3 > > [EMAIL PROTECTED] ~ $ bleadperl test.pl > 3.55, 3
It's down to the different ways Perl_sv_2pv_flags handles magic and non-magic values. In the former case, it does mg_get(), which happens to set the SV with NOK,pIOK,pNOK flags and IV = 3, NV = 3.55. Then, the C<if (SvGMAGICAL(sv))> branch prefers I over N: if (SvIOKp(sv)) { .... goto tokensave; } if (SvNOKp(sv)) { so stringifies to "3". The non-magical branch only does the I thing if there isn't an N thing: if (SvIOK(sv) || ((SvIOKp(sv) && !SvNOKp(sv)))) { so it stringifies to "3.55". I wouldn't really like to venture what the correct fix is, epecially as I'm still consfused about the meanings of the public verses private N/I/P flags. -- Wesley Crusher gets beaten up by his classmates for being a smarmy git, and consequently has a go at making some friends of his own age for a change. -- Things That Never Happen in "Star Trek" #18