in reply to Question on Reading a file inside while and counting no.of lines
You have been given three good answers, but I especially support Davido's recommendation to use the "$." variable (line count in the file being read) rather than counting yourself the line number. It is simpler, easier and probably faster.
In Section
Seekers of Perl Wisdom