Re^3: Find & Delete by comparing two filesby nemesdani (Friar)
|on Sep 11, 2012 at 10:00 UTC||Need Help??|
A few general suggestions (I haven't read your code thoroughly, sorry):
Pack your things (e.g. If the Link is broken, it is testing it if there's only a problem with the subfolder and generating a new url. Testing the head of this link) together in subroutines, your code will be clearer, more scalable.
Open and write to files once, don't open them every time. (time, performance)
About the question: If you find a broken link, you could save the line numbers in an array, and after you checked each line, you can delete the lines.
One solution that comes into my head is with Tie::File
Example of deleting the last line from a file, stolen from the Cookbook (hellyea, I am lazy):
I'm too lazy to be proud of being impatient.