### Comment on

 Need Help??
I feel the need to ask, might it be easier to convert your numbers to the other firm's numbers? Or maybe not try to convert anyone's numbers, but use both yours and theirs and match them up using a database or something? Maybe if I understood how and why they seem to add 0 in very odd places, it would be easier to figure out how to deal with this. I'm not a regex person, so this is my stab at this:
```#!/usr/bin/perl

use strict;

# We want to do the following:

#counting starts at 0
# the 0 , 1 digits shoud be untouched
# if the 2 digit is a 0 and the next digit is a 0 remove all 0 untill
+first non 0
# if the 2 digit a 0 and the next is a non 0 remove the 0
# if the 3 digit is a 0 and follows by a 0 then remove all 0 except th
+e 0 at 3 digit
# if the 3 digit is a 0 and the next digit is a non 0 remove only the
+0
# if the 4 digit is a 0 remove it and all following 0 untill non 0

foreach my \$number (<DATA>) {

chomp(\$number);
#  print \$number . "\n";

my @digits = split("", \$number);
my \$newnumber;

my \$i = 0;
for (\$i=0; exists(\$digits[\$i]); \$i++) {
#    print "I:\$i, " . \$digits[\$i] . "\n";

if (\$i < 2) {
# 0, 1 digits should be untouched
\$newnumber .= \$digits[\$i];
next;

} elsif (\$i == 2) {
# if the 2 digit is a 0 and the next digit is a 0 remove all 0 u
+ntill first non 0
# if the 2 digit a 0 and the next is a non 0 remove the 0

if (\$digits[\$i] > 0) {

\$newnumber .= \$digits[\$i];
next;
} elsif ((\$digits[2] == 0) && (\$digits[3] == 0)) {
for(my \$j = 2; \$digits[\$j] == 0; \$j++) {
\$i++; # we skip this digit

}
\$newnumber .= \$digits[\$i];

} # no need for another else b/c we remove the 0 anyway

} elsif (\$i ==3) {

# if the 3 digit is a 0 and follows by a 0 then remove all 0 exc
+ept the 0 at 3 digit
# if the 3 digit is a 0 and the next digit is a non 0 remove onl
+y the 0
if ((\$digits[3] == 0) && (\$digits[4] > 0)) {

next;

} elsif((\$digits[3] == 0)  && (\$digits[4] == 0)){

\$newnumber .= \$digits[\$i];
for (my \$j = 4; \$digits[\$j] == 0; \$j++) {

\$i++;

}
\$newnumber .= \$digits[\$i];

}

} elsif (\$i == 4) {

# if the 4 digit is a 0 remove it and all following 0 untill non
+ 0

if (\$digits[4] == 0) {

for (my \$j=4; \$digits[\$j] == 0; \$j++) {

\$i++;

}

\$newnumber .= \$digits[\$i];

} else {

\$newnumber .= \$digits[\$i];

}

} else {

\$newnumber .= \$digits[\$i];

}

}

print "\$number -> \$newnumber\n";

}

__DATA__

215000007801
300000324002
890000457651
210004563401
201045139158
I'm sure there is a serious performance hit for not using a regex.
Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
 [Corion]: Ugh - the FSF wants to merge Magit into Emacs (or rewrite Magit). It seems they haven't learned from Perl+CPAN that not having things in core is good.

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2017-07-21 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
I came, I saw, I ...

Results (321 votes). Check out past polls.