View Single Post

   
  #4 (permalink)  
Old 05-07-2008, 10:15 AM
Serman D.
 
Posts: n/a
Default Re: How to add leading zeroes

On May 5, 5:27 pm, "lenygold via DBMonster.com" <u41482@uwe> wrote:

> Any idea how to produce requested result?


I would have used perl:

$ cat /tmp/foo.pl
use strict;
use warnings;

while(my $line = <DATA>){
print join(q{.}, map { sprintf("%03d", $_); } split(/\./,
$line));
}

__DATA__
1.4.1
1.10.1
1.10.1.2.2
1.22.99.1
2
2.8.11
2.7.7

$ perl -wl /tmp/foo.pl
001.004.001
001.010.001
001.010.001.002.002
001.022.099.001
002
002.008.011
002.007.007

--
Serman D.
Reply With Quote