in reply to sprintf zero-fill issue

In addition to unsigned, you could also indicate them as a string, assuming your inputs are strings (as they are in the example you provided).
printf("%014s", $var1); printf("%014s", $var2);
Of course, I can't say for sure that wouldn't cause some other unforeseen issue. just my $0.02