Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Find & Delete by comparing two files

by nemesdani (Friar)
on Sep 11, 2012 at 10:00 UTC ( #992968=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Find & Delete by comparing two files
in thread Find & Delete by comparing two files

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):

use Tie::File; tie @lines, Tie::File, $file or die "can't update $file: $!"; delete $lines[-1];

I'm too lazy to be proud of being impatient.


Comment on Re^3: Find & Delete by comparing two files
Select or Download Code
Re^4: Find & Delete by comparing two files
by perlpoda (Initiate) on Sep 11, 2012 at 13:17 UTC
    Hi nemesdani, thanks for your input I will try to work that into my code. Let's see if it works out :) Thanks - Regards, Robert

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://992968]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-09-16 09:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (158 votes), past polls