pccode has asked for the wisdom of the Perl Monks concerning the following question:
However, I don't know if that will create any problems with the rest of the program. To save space on this page I'm only going to post the code that I've added to the lwp-program. You can download the complete program at http://parasoft.netfirms.com/.my $shown++;
There are two problems with the program. It only executes the first getFile subroutine before it exits and it overwrites existing files without prompting. How can I fix this? Thanks.use warnings; use strict; # Enter the local directory to save downloaded files into my $savelocation = "c:\\docume~1\\name\\desktop\\downloads\\"; # If directory does not exist, create it opendir(FINDDIR, $savelocation) || mkdir($savelocation); closedir FINDDIR; # Use the subroutine below for each file you need to download &getFile("http://www.domainname.com/file.png"); &getFile("http://www.domainname.com/file.txt"); sub getFile { my $netlocation = $_[0]; my @directories = split(/\//, $netlocation); my $fname = pop(@directories); &Download($netlocation, "$savelocation$fname"); } sub Download { # the entire lwp-download program }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: lwp-download program
by holli (Abbot) on May 29, 2005 at 19:59 UTC | |
by pccode (Novice) on May 29, 2005 at 20:13 UTC | |
|
Re: lwp-download program
by Zaxo (Archbishop) on May 29, 2005 at 20:07 UTC | |
by pccode (Novice) on May 29, 2005 at 20:24 UTC | |
by pccode (Novice) on May 29, 2005 at 20:32 UTC |