Dr.Ruud wrote:
> Rob Dixon schreef:
>> Dr.Ruud wrote:
> 
>>> That Data::Dumper prefers to print the numeric face of the variable,
>>> if available, is a matter of choice inside the code of Data::Dumper.
>>> Maybe the other modules that you use, have Data::Dumper embedded?
>>
>> That is not true.
> 
> I am not sure which of the above you consider not true, so I'll show it
> with a variant of your own code.
> My "if available" is equivalent to the "PVIV with IOK" that Devel::Peek
> shows.
> 
> $ perl -wle'
> use strict;
> use warnings;
> 
> use Devel::Peek qw/Dump/;
> 
> my $s = "1234";
> Dump $s;
> 
> 1 if $s == 0;
> Dump $s;
> 
> 1 if $s eq "foo";
> Dump $s;
> '
> SV = PV(0x89b2ef8) at 0x89c8c30
>   REFCNT = 1
>   FLAGS = (PADBUSY,PADMY,POK,pPOK)
>   PV = 0x89c2030 "1234"\0
>   CUR = 4
>   LEN = 5
> SV = PVIV(0x89b3308) at 0x89c8c30
>   REFCNT = 1
>   FLAGS = (PADBUSY,PADMY,IOK,POK,pIOK,pPOK)
>   IV = 1234
>   PV = 0x89c2030 "1234"\0
>   CUR = 4
>   LEN = 5
> SV = PVIV(0x89b3308) at 0x89c8c30
>   REFCNT = 1
>   FLAGS = (PADBUSY,PADMY,IOK,POK,pIOK,pPOK)
>   IV = 1234
>   PV = 0x89c2030 "1234"\0
>   CUR = 4
>   LEN = 5
> 
> The second dump shows that both IOK and POK are. In that case
> Data::Dumper (takes the choice and) prefers the numeric
> variant/face/value/representation.

That is not a variant of my code, it is very different indeed. Here is what I 
coded

> use strict;
> use warnings;
> 
> use Devel::Peek qw/Dump/;
> 
> my $numstr = sprintf("%4d", 1234);
> Dump $numstr;
> 
> $numstr = sprintf("%05d", 1234);
> Dump $numstr;
> 
> my $num = sprintf("%05d", 1234);
> $num += 0;
> Dump $num;

And that is identical to the OP's, except that I added warnings and strictures,
removed an unnecessary 'my' that threw a warning, and called Devel::Peek::Dump
instead of Data::Dumper::Dumper.

The post you made that I was correcting said,

> It is not "in number data type", it is merely available as numeric. (as
> I have said before)

And I showed with the output from my program that

  my $num = sprintf("%05d", 1234);
  $num += 0;
  Dump $num;

gives the output

  SV = PVIV(0x37604) at 0x357c4
  REFCNT = 1
  FLAGS = (PADBUSY,PADMY,IOK,pIOK)
  IV = 1234
  PV = 0x183ba74 "01234"\0
  CUR = 5
  LEN = 8

so the data is indeed "in number data type", and is unavailable in any other
form without further conversion.

The fact that completely different program produces completely different results
is hardly a useful thing to be telling us.

Please try to quote relevant parts of the posts you respond to in future.

Rob


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to