http://www.perlmonks.org?node_id=143505


in reply to Dropping Leading Zeros

i couldn't quite understand the question... but from the title of the post.. you want to remove leading zeros
$number = '00000000000005341390432'; $number =~ s/^0+//; print $number;
would output: 5341390432

Replies are listed 'Best First'.
Re: Re: Dropping Leading Zeros
by Sweeper (Pilgrim) on Feb 06, 2002 at 06:32 UTC
    i couldn't quite understand the question... but from the title of the post.. you want to remove leading zeros

    On the contrary, in his case, his program drops zeros that should be kept (zip codes, phone numbers). Your answer is valid, but off-topic. Yet, I did not downvote you, you wanted to help.

    Back to the question. I think that the real problem is that in the database, phone numbers and zip codes are described as numbers, and this is wrong. Phone numbers are strings, not numbers (consider 1-800-COLLECT), and zip codes are strings, not numbers (consider British and Canadian zip codes). Like gellyfish said, a few lines of code would help (do not post your whole program, yet, just select the few lines in question).