finding distance between numbers

Hi,

I have a file as

ABC 1634230,1634284,1634349,1634468 1634272,1634301,1634356,1634534

What I want is to find distance between the numbers.. column 1 is the gene name and column 2 are starts and column 3 are their respective stops for the starts. So what I want is column 3 which has +1 added to each value in column 2 except for the last value and -1 subtracted to each value except for the 1st value in column 1..

output:

 ABC 1634230,1634284,1634349,1634468  1634272,1634301,1634356,1634534 1634283,1634348,1634467 1634273,1634302,1634357

I have 40,000 such rows

Thanks,

$
$
$ cat f37
ABC 1634230,1634284,1634349,1634468 1634272,1634301,1634356,1634534
PQR 10,9,8,7 1,2,3,4
$
$
$ perl -ane '@x = map {$_ - 1} split/,/, $F[1];
             @y = map {$_ + 1} split/,/, $F[2];
             printf ("%s %s %s\n", "@F", join(",", @x[1..$#x]), join(",", @y[0..$#y-1]))
            ' f37
ABC 1634230,1634284,1634349,1634468 1634272,1634301,1634356,1634534 1634283,1634348,1634467 1634273,1634302,1634357
PQR 10,9,8,7 1,2,3,4 8,7,6 2,3,4
$
$

tyler_durden

awk -F'[ ,]' '{print $0" "$3-1","$4-1","$5-1" "$6+1","$7+1","$8+1}' infile