You have interspersed your code with prose making it more difficult to download and analyse. Do not do that. Wrap your prose in <p> tags and your data and code in <code> tags instead, please.
Here is a one-liner which does what you want. Add -i to edit in-place (see perlrun)
perl -lpe '$s{$_}++; s/;$/_$s{$_};/' foo.txt
🦛
In reply to Re: To remove duplicate lines and add digits as per loop
by hippo
in thread To remove duplicate lines and add digits as per loop
by suvendra123
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |