in reply to sprintf() returning incorrect value

Can't reproduce:

my $nfc_amt = 115; print "NFC_AMT before adding zeroes: $nfc_amt\n"; $nfc_amt = sprintf("%07d", $nfc_amt); print "NFC_AMT after adding zeroes: $nfc_amt\n"; __END__ NFC_AMT before adding zeroes: 115 NFC_AMT after adding zeroes: 0000115

Likely it doesn't contain what you think it contains. Could you add this to your code and show us the output: use Devel::Peek; Dump($nfc_amt);

Replies are listed 'Best First'.
Re^2: sprintf() returning incorrect value
by ppeel (Novice) on Jul 15, 2015 at 15:24 UTC

    Added the Dump and this is the result: NFC_AMT before adding zeroes: 115 SV = NFC_AMT after adding zeroes: 0000114 PVNV(0x24cb13c) at 0x256709c REFCNT = 1 FLAGS = (PADMY,NOK,POK,pNOK,pPOK) IV = 0 NV = 115 PV = 0x271042c "115"\0 CUR = 3 LEN = 36