How can I remove all the leading zeroes but leave a final zero if the value only contains zeroes?
for example:
my $number = \"0000\";
If your $number is an integer, another way is to use printf:
$number
for my $number (qw(005 05 5 000 0 500)) { printf "%d\n", $number; } __END__ 5 5 5 0 0 500
Edit: As ysth points out, it works for all integers, not just positive integers as I originally stated.