just dave has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks !
I have a nice program that runs well, that is untill I've added a a small piece of code...
my $firstValue = getField($filename,$fieldName,$lastValue); my $secondValue = getField($secondFileName,$secondFieldName,$lastValue); my $sumValue = $firstValue + $secondValue; $hash_of_oids{$request->getOID()}->{'lastValue'} = $sumValue; $request->setValue($fieldtype, $sumValue);
Now, my first problem is that my error does not allways happen !! but when it does I get this reply:
Non-integer value passed to setValue with ASN_INTEGER: type was 6
nNow, the getField metho returns integers since I use it a lot before this part, moreover, it also prints the numbers ! so I know that $firstValue and $secondValue are returning the correct values.

So, my guess is that $sumValue for some reson is no longer an integer, and that's why the setValue throws this error

but why ?
please help !
Thank you all
Dave

jdporter added missing markup

Replies are listed 'Best First'.
Re: Wrong value used
by Tanktalus (Canon) on Dec 25, 2005 at 14:47 UTC

    I think it should be somewhat obvious that $sumValue must be integral unless $firstValue and $secondValue are not ... or if their sum is too high to be represented in your native integer types.

    So, I'd suggest some debugging techniques, such as printing out the $firstValue and $secondValue before setting $sumValue, to make sure they are what you think they are, and to check if they are about to wrap the native integer type for your platform. e.g., if you're using 32-bit perl, chances are that the maximum integer is about 4 billion (2**32-1), while if you're using 64-bit perl, or 32-bit perl with use64bitint defined, the maximum is about 4 billion squared (2**64-1).

    Of course, I'd also check what $sumValue was right before sending it to setValue. Never hurts to double-check.

Re: Wrong value used
by idsfa (Vicar) on Dec 25, 2005 at 18:50 UTC

    What's the value of $fieldtype? Is it the 6 that your error message implies, or does that come from somewhere else?


    The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon