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

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.

Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2016-10-25 03:15 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (313 votes). Check out past polls.