You've been given some good solutions already, and my guess is that if you use a regex substitution (
transliteration operator, you probably no longer need to keep track of the line number. But if you need to track the line number for some other reason, please be advised that the
special variable does that automatically for you (it reports the current input line number of the last file handle that was read).