How can I remove all the leading zeroes but leave a final zero if the value only contains zeroes?
for example:
my $number = \"0000\";
Just add 0 to the string so that it's implicitly converted to a number:
my $var = '0000035600000'; $var += 0;