in reply to Want to know Line number of the input file

You could maintain a status file. Open it once, at the beginning, then seek($stat_hf, 0, 0); just before you write the current status to the file. This is a lot of extra IO, so you might want to do it once every 5 or 10 input lines.

Unfortunately, some operating systems might auto-lock the status file against even reads from other processes. The preferred "fix" for that is to open it with options to only lock the file for writes. (but I don't know how to do that.) A common work-around is to close and re-open the file for each update. This incurs much more extra IO, so you'd only want to update once for every 50 or 100 input lines.