slayedbylucifer has asked for the wisdom of the Perl Monks concerning the following question:
hello Monks,
I need some regex help. I have a csv where in I want to edit the 35th field. In 35th field, I want to replace the "0" which is in the beginning of the string "and" is followed by 10 digits with "+91" and then write the change back. I do not want the output on the console but want to have it written back to the same file in the same field.
I thought this would have been an easier one with sed/awk but I could not yet make it work. Here is my thread with the sed/awk exploration:
http://stackoverflow.com/questions/11138434/sed-in-place-replacement
So, Now I am thinking of doing it with perl. Here is one sample input:
foo,foo,foo,,,,,,,,,,,,,,,,,,,,,,,* My Contacts ::: Phone Only,,,,,,,M +obile,02234567899,,,,,,,,,,,,,,,,,
So in above line, the number happens to be the 35th field. I want to change it from "01234567899" to "+912234567899".
Please provide your inputs.
-Thanks.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: edit a CSV and "in-place" replacement
by Tux (Canon) on Jun 22, 2012 at 06:47 UTC | |
by slayedbylucifer (Scribe) on Jun 22, 2012 at 07:57 UTC | |
Re: edit a CSV and "in-place" replacement
by slayedbylucifer (Scribe) on Jun 22, 2012 at 06:43 UTC | |
by bitingduck (Chaplain) on Jun 22, 2012 at 07:03 UTC | |
by slayedbylucifer (Scribe) on Jun 22, 2012 at 07:48 UTC | |
by bitingduck (Chaplain) on Jun 22, 2012 at 08:02 UTC | |
by Tux (Canon) on Jun 22, 2012 at 09:31 UTC | |
Re: edit a CSV and "in-place" replacement
by sundialsvc4 (Abbot) on Jun 22, 2012 at 19:00 UTC |