ppeel has asked for the wisdom of the Perl Monks concerning the following question:
I need to add leading zeroes to a variable $nfc_amt, so I'm using sprint() to do that. however when $nfc_amt = 115, the value returned is 0000114. What am I doing wrong?
print "NFC_AMT before adding zeroes: $nfc_amt\n"; $nfc_amt = sprintf("%07d", $nfc_amt); print "NFC_AMT after adding zeroes: $nfc_amt\n";
This is the result I get:
NFC_AMT before adding zeroes: 115
NFC_AMT after adding zeroes: 0000114
|
|---|