in reply to Re: How to find a number and replace it with calculated value?
in thread How to find a number and replace it with calculated value?

Thanks toolic, that's what i wanted. just a small issue, the increment of occurrence number is per line, how to make it per file or multipleline?
  • Comment on Re^2: How to find a number and replace it with calculated value?

Replies are listed 'Best First'.
Re^3: How to find a number and replace it with calculated value?
by AnomalousMonk (Archbishop) on Mar 03, 2017 at 21:20 UTC
    ... the increment of occurrence number is per line, how to make it per file or multipleline?

    Move the  my $i = 1; statement to before the loop (untested):

    my $i = 1; while (<DATA>) { ... s/\b(XP)\b/$1 . ' (' . $i++ . ')'/eg; print; }


    Give a man a fish:  <%-{-{-{-<

      It did it :) thank you guys.