[EMAIL PROTECTED] wrote: > Hi, > > While reading each line in a file, If I find a certain number, I need to > increment a digit within that number. For example, when reading through my > file, I expect to find the following line. > > #define DS_FILEVERSION 7,0,0,0462 > > What I want to do is have the ability to increment the first two zero's > after the 7 on demand. I may accasionaly want to increment the first zero, > making the number 7,1,0,0462, or a I may want to just increment the second > zero, making the number 7,0,1,0462 >
hopefully something like that will work for you: #!/usr/bin/perl -w use strict; my $i = 0; while(<>){ /DS_FILEVERSION/ && s/,(\d),(\d)/++$i % 2 ? ",$1,@{[$2+1]}" : ",@{[$1+1]},$2"/e; print; } __END__ david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]