In essence, you're starting at the top of the file, and then just repeating 10 times: read from the current position to the end of the file. After the first time through the loop, you've reached the end of the file (by the nature of your while loop), so the subsequent iterations simply read from the end of the file to the end of the file. Which results in nothing happening. I suspect you need to add last after sending the line to NEW_OUTPUT_XML_A
To add to the confusion: $line=~/^(\d{1,10})/) looks for a line starting with a number of up to ten digits. Which you then attempt to compare with value of $d. But that's only a single digit (1 to 9), so the vast majority of the time, that's not going to work. Why not look for a line starting with only a single digit? $line=~/^(\d)\D/?
--
Tommy
Too stupid to live.
Too stubborn to die.