in reply to splitting output to separate files, one per line

You have an opportunity to learn more than a solution to your immediate problem here. What the other respondents have used is a special perl variable $. which holds the current line number of the file being read. Read more at perldoc perlvar.