in reply to Re^2: Correct code for deleting old file?
in thread Correct code for deleting old file?
Your code contains lot of bad practices:
Also, you seem to go through great pains to handle URLs and to issue HTTP and FTP requests using wget. Perl has LWP, so you do not have to mess with the shell and external programs at all. Look first at LWP::Simple, that should nearly be sufficient to replace wget. If you need more control, look at LWP::UserAgent. As you seem to write a spider, also have a look at LWP::RobotUA.
Perl also can decompress gzip files and unpack tar files, if you like, even both in one package, Archive::Tar, and of course without having to mess with the shell.
For URL handling, look at URI and its helpers.
And for my personal taste, the getFile() function is about 200 lines longer than it should be. Too much code for one function, too deeply nested, too many variables. As a rule of thumb, a function should not exceed one screen, because otherwise, you will get lost in the code. At my university, a screen was defined as a VT420, i.e. 25 lines of no more than 80 characters, but in the real world, my editor shows about 40 lines of about 110 characters. Consider splitting the function into smaller parts.
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Correct code for deleting old file?
by Anonymous Monk on Jun 19, 2012 at 08:18 UTC |