Rajeev Prasad wrote:
$k=1; my $arSZ = @tmpAR=split(/"/,$line); for $x (0..$arSZ-1){ if ($x % 2 == 0) { push(@modline,"$tmpAR[$x]"); } else { my $count = $tmpAR[$x-1] =~ tr/,/,/; #try for something more correct like... =~ m/\,/g); $k = $k + $count; push(@modline,"STRING.$k"); } print @modline; this replaces fields in quotes with STRING-field number.
That rather complicated code could be replaced with: my $k = 1; my @tmpAR = split /"/, $line; for ( my $x = 0; $x <= $#tmpAR; $x += 2 ) { $k += $tmpAR[ $x ] =~ tr/,//; push @modline, $tmpAR[ $x ], "STRING.$k"; } print @modline; John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/