>>>>> "PK" == Parag Kalra <[email protected]> writes:
PK> use strict;
PK> use warnings;
PK> while(<DATA>){
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 . $. - 1 . $3/e ;
you could simplify the regex by assuming the only number is in the
middle as the data shows.
s/\d+/$. - 1/e ;
PK> print $_;
no need for the $_ as print defaults to printing it.
also please learn to edit quoted emails and to put your post below it.
uri
--
Uri Guttman -- uri AT perlhunter DOT com --- http://www.perlhunter.com --
------------ Perl Developer Recruiting and Placement Services -------------
----- Perl Code Review, Architecture, Development, Training, Support -------
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/