Hello,
See if the following stuff helps you :
Following is content of all.m3u file.
$ cat all.m3u
http://www.manning-source.com/books/...cher2_chp1.pdf
http://www.manning-source.com/books/...cher2_chp3.pdf
http://www.manning-source.com/books/...cher2_chp4.pdf
$
Following is the script which can be used to download the above files.
$ cat download.pl
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
my $filelist = 'all.m3u';
open (FILE, $filelist) or die "Not able to open $filelist : $!";
foreach my $file (<FILE>) {
chomp($file); ## remove the last \n
my @filearray = split /\//, $file;
my $filename = pop @filearray;
print "Downloading : $filename" . "\n";
my $status = getstore($file, $filename);
if(is_success($status)) { print ("Download of $filename
complete\n");}
else { print ("Download of $filename failed\n"); }
}
close (FILE);
If you want to keep the directory structure consitent, you have to
workout on $filename variable which is constucted from $file, the line
of all.m3u file.
you can add some stuff there so that directories are created and the
files are stored in those directories.
Regards,
--sopan shewale
heli0s wrote:
> Hi,
>
> I'm having a bit of a problem with a script I'm writing. I want the script
> to read in a txt file with a list of files to download and then go through
> the list of files to get them from the net.
>
> it should be something like this:
>
> use LWP::Simple;
>
> open (FILE,"all.m3u");
> @file = <FILE>;
> close FILE;
>
> foreach $line (@file){
> get ( $line );
> }
>
> As seen in the above code, i've been looking at LWP::Simple, but what i
> have here is no good. Maybe i'm doing something wrong but i havent figured
> it out yet.
>
> Greets Christiaan