Can you please modify it.
I can, but I won't because you have made a trivial mistake that you can find easily yourself by examining the code and the output from the program and thinking a little. You should run the code in a console so that you see any errors, warnings or output generated when you run the script.
I note too that you ignored my advice to use lexical file handles and the three parameter open so I've no confidence that you'll take notice of anything else I suggest. On the off chance that you are taking notice though, the increment of $num doesn't need to be conditional - the for loop has already done the counting for you. Making it conditional is misinformation - it looks like there could be ways of getting to that line when the increment shouldn't happen and that is not the case.
True laziness is hard work
|