use strict; use warnings; while(<DATA>){ my $num = $. - 1; s/\d+/$num/ if /\w+\s+\d+\s+\w/; print $_; }
__DATA__ charith 4 matara saman 8 kandy andrew 9 colombo dilshan 3 galle shanil 10 jafna Parag On Fri, Sep 2, 2011 at 8:42 PM, Charith LokuBogahawatta <charith...@gmail.com> wrote: > Hi All, > > I'm new to this group also for perl but nowadays I working around with > Perl and I need some help. this my first thread please anyone can help > me? > > i have a file contains the following data. > > charith 4 matara > saman 8 kandy > andrew 9 colombo > dilshan 3 galle > shanil 10 jafna > . > . > . > Here I want to replace second column (Number) with incremental number > sequence. output should be following. > > charith 0 matara > saman 1 kandy > andrew 2 colombo > dilshan 3 galle > shanil 4 jafna > . > . > . > > Thank you very much > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/