sathya83aa has asked for the wisdom of the Perl Monks concerning the following question:
Hi all..
I have peculiar issue in one of my code where Im using sprintf. Please have a look into it and any help on this will be appreciated.
$Val2 = trim(substr($line2,80,11)); print "Value obtained = $Val2\n"; $Val1 = $Val2; print "Value assigned = $Val1\n"; $Val1 = sprintf("%11d", $Val1); print "Value eleven digit = $Val1\n"; $Val1 =~ s/ /0/g; print "Value replaced = $Val1\n";
Output while running this script :
Value obtained = 12143951645 Value assigned = 12143951645 Value eleven digit = -1 Value replaced = 000000000-1
The output "Value eleven digit" printed after sprintf has been printed as -1. Can someone please help me with this issue?
Thanks & Regards,
Sathya V.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: issue with sprintf..
by LanX (Saint) on Jan 09, 2014 at 10:27 UTC | |
by sathya83aa (Acolyte) on Jan 09, 2014 at 10:35 UTC | |
by LanX (Saint) on Jan 09, 2014 at 10:38 UTC | |
by sathya83aa (Acolyte) on Jan 09, 2014 at 11:45 UTC | |
by hdb (Monsignor) on Jan 09, 2014 at 10:45 UTC | |
|
Re: issue with sprintf..
by hdb (Monsignor) on Jan 09, 2014 at 10:28 UTC | |
by LanX (Saint) on Jan 09, 2014 at 10:30 UTC | |
by hdb (Monsignor) on Jan 09, 2014 at 10:32 UTC | |
by LanX (Saint) on Jan 09, 2014 at 10:33 UTC | |
by hdb (Monsignor) on Jan 09, 2014 at 10:37 UTC | |
| |
|
Re: issue with sprintf.. (%s and %ll$)
by LanX (Saint) on Jan 09, 2014 at 11:07 UTC |