in reply to Adding Leading Zeros

Don't laugh, This is some of my REALLY old code but it proves that there is ALWAYS more than one way...

$var = "0000000000"; substr($var, -length($ARGV[0])) = "$ARGV[0]"; print "$var\n";

-----
Of all the things I've lost in my life, its my mind I miss the most.

Replies are listed 'Best First'.
Re^2: Adding Leading Zeros
by tusty (Novice) on Mar 15, 2016 at 09:26 UTC
    I have a silly question here. Why does the following code return 000000001739 and how do I fix this? perl -e 'printf("%012d", 17.40 * 100);'