William schreef:
> [*attribution dammit*] Ruud:

>> There is no real way to test if a value inside a variable has a
>> numeric "personality". Variables can have multiple "personalities",
>> each with there own binary value.
>>
>> So maybe the problem just comes from the leading zeroes that your
>> sprintf format added?
>
> Not exactly from the leading zeros,
>
> use Data::Dumper;
> my $numStr = sprintf("%4d", 1234);
> print (Dumper $numStr), "\n";
>
> my $numStr = sprintf("%05d", 1234);
> print (Dumper $numStr), "\n";
>
> my $num = sprintf("%05d", 1234);
> $num += 0;
> print (Dumper $num), "\n";
>
>
>   use Language::Prolog::Types::overload;
>
>   use Language::Prolog::Types qw(:ctors);
>
>   print prolog_functor('foo', $numStr), "\n";
>   print prolog_functor('foo', $num), "\n";
>
>
> $VAR1 = '1234';
> $VAR1 = '01234';
> $VAR1 = 1234;
> foo(01234)
> foo(1234)
>
>
> As you can see the last of $VAR1 does not have single quote, so it's
> really in number data type.

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


> I think so far, adding zero solve the problem.

That is indeed one of the ways to add a numeric personality to a
variable.
Testing with a numeric operator also "works", see below:

$ perl -Mstrict -Mwarnings -MData::Dumper -wle'
   my $s = "1234";
   print Dumper($s);
   print 1 if $s == 0;
   print Dumper($s);
   print 2 if $s eq "1234";
   print Dumper($s);
'
$VAR1 = '1234';

$VAR1 = 1234;

2
$VAR1 = 1234;

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?

-- 
Affijn, Ruud

"Gewoon is een tijger."


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


Reply via email to