in reply to sprintf() returning incorrect value

Welcome ppeel,

This may be my experience only, but I've had problems keeping leading zeros ('0'), in a variable ( especially hashes and arrays ) within a long running script. So instead of using 'sprintf', I usually add a number with the correct number of zeros, and then use 'substr' to remove it when I need to print, etc. So your:

$nfc_amt = sprintf("%07f", $nfc_amt);
becomes for me:
$nfc_amt = $nfc_amt + 10000000; # or $nfc_amt += 10000000;
Then when I need to print/etc. the result, I do:
print "NFC_AMT after adding zeroes: ",substr($nfc_amt,1),"\n";
I have only experienced this when I add the zeros and then use the variables much later. YMMV. (Note: It also could have been a bug in the version of Perl that I was using which is now fixed. :-)

Regards...Ed

"Well done is better than well said." - Benjamin Franklin