http://qs1969.pair.com?node_id=759770


in reply to Problem with accessing hash Module::CoreList::version with $]

Apparently, this special variable is only a string in perl 5.10, even though the documentation seems to suggest that it be a floating point number. If you use $]+0 in your example, it'll work (which is kind of strange because ordinary hash keys are converted to strings anyway, but in this case I think we are dealing with a tied hash).

% perl5.8.8 -we 'use Devel::Peek; Dump $]' SV = PVNV(0x9f664d0) at 0x9f63ed0 REFCNT = 1 FLAGS = (NOK,POK,READONLY,pNOK,pPOK) IV = 0 NV = 5.008008 # <-- in 5.8 it was a number PV = 0x9f7d250 "5.008008"\0 CUR = 8 LEN = 12 % perl5.10.0 -we 'use Devel::Peek; Dump $]' SV = PV(0x9457198) at 0x946a610 REFCNT = 1 FLAGS = (POK,READONLY,pPOK) PV = 0x945e538 "5.010000"\0 CUR = 8 LEN = 12

Replies are listed 'Best First'.
Re^2: Problem with accessing hash Module::CoreList::version with $]
by XooR (Beadle) on Apr 24, 2009 at 10:39 UTC
    betterworld sad:
    Apparently, this special variable is only a string in perl 5.10, even though the documentation seems to suggest that it be a floating point number. If you use $]+0 in your example, it'll work (which is kind of strange because ordinary hash keys are converted to strings anyway, but in this case I think we are dealing with a tied hash).
    Thanx, that's solved it. I will read about tied hashes and see if this is a problem.
Re^2: Problem with accessing hash Module::CoreList::version with $]
by Anonymous Monk on Apr 24, 2009 at 10:13 UTC
    Actually that makes no difference, works just fine in 5.10. His problem is he expect Data::Dumper output to be identical. Maybe if he use $Data::Dumper::Sortkeys ... or this
    #!/usr/bin/perl use strict; use warnings; use Module::CoreList; use Data::Dumper; $Data::Dumper::Sortkeys=1; print Dumper( $Module::CoreList::version{ $] }, $Module::CoreList::version{ "$]" }, $Module::CoreList::version{ 5.010000 } ); __END__ $VAR1 = { 'AnyDBM_File' => '1.00', ..... }; $VAR2 = $VAR1; $VAR3 = $VAR1;