Re: please Perl help...

2011-09-04 Thread Shlomi Fish
Hi Parag, a few comments on your code. On Sat, 3 Sep 2011 23:38:31 -0700 Parag Kalra wrote: > use strict; > use warnings; > while(){ You should expect the contents of the file to be in a different place than __DATA__, so one should use open or *ARGV or whatever here. > my $num = $. - 1;

Re: please Perl help...

2011-09-03 Thread Uri Guttman
> "PK" == Parag Kalra writes: PK> use strict; PK> use warnings; PK> while(){ PK> my $num = $. - 1; PK> s/\d+/$num/ if /\w+\s+\d+\s+\w/; there is no need for the if as you can just do a s/// directly. and it can do the num part as well. s/(\w+\s+)\d+(\s+\w+)/$1 . $

Re: please Perl help...

2011-09-03 Thread Parag Kalra
use strict; use warnings; while(){ 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 wrote: > Hi All, > > I'm new to

Re: please Perl help...

2011-09-03 Thread Shlomi Fish
ׁHi Charith, On Fri, 2 Sep 2011 20:42:31 -0700 (PDT) Charith LokuBogahawatta 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.

please Perl help...

2011-09-03 Thread Charith LokuBogahawatta
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