Question Details

No question body available.

Tags

regex perl one-liner

Answers (1)

February 5, 2026 Score: 3 Rep: 45,627 Quality: Medium Completeness: 80%

If you're sure the i and j will alway be integers, the simplest way is to use /e:

perl -pwe 's/^(\d+),\s*(\d+)/($1+1).", ".($2+1)/e' ./raw

gives

1, 1, (1.263566e+02, -5.062154e+02)
1, 2, (1.069488e+02, -1.636887e+02)
1, 3, (-2.281294e-01, -7.787449e-01)
1, 4, (5.492424e+00, -4.145492e+01)
1, 5, (-7.961223e-01, 2.740912e+01)

The /e enables right side expression evaluation: perlop

e   Evaluate the right side as an expression.
ee  Evaluate the right side as a string then eval the
    result.
r   Return substitution and leave the original string
    untouched.

The .", ". is a simple string concatenation to easily back the , between i and j.