Simple automated file retriever

scot on 2007-01-02T18:27:24

I whipped this together to grab web pages on a daily basis:

use strict; use LWP::Simple; use Time::localtime; use File::Basename;

open (DATA, "urllist.txt") || die "File open failure!"; while (my $downloadurl = <DATA>){ (my $name, my $path, my $suffix) = fileparse($downloadurl); my $finurl = $downloadurl; print $finurl."\n"; my $lt = localtime(); my $now_string = $lt->mon." ".$lt->mday;

my $savefilename = $now_string.$name.$suffix; print $savefilename; print "\n"; my $status = getstore($finurl,$savefilename); print $status."\n" } <\code>


small change to get suffix working properly

prahl on 2007-01-02T20:46:22

I needed to do this

(my $name, my $path, my $suffix) = fileparse($downloadurl,qr{\..*});

so that the $suffix works as expected

Re:small change to get suffix working properly

scot on 2007-01-02T21:11:09

What platform are you running this on? Mine is WinXP SP2.