use warnings; use strict; use File::Fetch; unlink '/tmp/xbrltest/xbrlrss-2015-09.xml'; unlink '/tmp/xbrltest/xbrlrss-2015-10.xml'; unlink '/tmp/xbrltest/xbrlrss-2015-11.xml'; if (-e '/tmp/xbrltest/xbrlrss-2015-09.xml') { print "File 09 Exists\n"; } else {print "Need to Download 09\n";} if (-e '/tmp/xbrltest/xbrlrss-2015-10.xml') { print "File 10 Exists\n"; } else {print "Need to Download 10\n";} if (-e '/tmp/xbrltest/xbrlrss-2015-11.xml') { print "File 11 Exists\n"; } else {print "Need to Download 11\n";} { print "Fetching File with URL in double quotes\n"; my $url="http://www.sec.gov/Archives/edgar/monthly/xbrlrss-2015-09.xml"; my $ff = File::Fetch->new(uri=>$url) or die("Something went wrong in fetching file: $!"); my $where = $ff->fetch(to=>'/tmp/xbrltest/') or die $ff->error; } { print "Fetching File with URL in single quotes\n"; my $url = 'http://www.sec.gov/Archives/edgar/monthly/xbrlrss-2015-10.xml'; my $ff = File::Fetch->new(uri=>$url) or die("Something went wrong in Fetching RSS Feed: $!"); my $where = $ff->fetch(to=>'/tmp/xbrltest/') or die $ff->error; } { print "Fetching File with URL built from parts\n"; my $year = '2015'; my $month = '11'; my $site = 'http://www.sec.gov/Archives/edgar/monthly/'; my $rssFile = "xbrlrss-" . $year . "-" . $month . ".xml"; my $url = $site . $rssFile; my $ff = File::Fetch->new(uri=>$url) or die("Something went wrong in Fetching RSS Feed: $!"); my $where = $ff->fetch(to => '/tmp/xbrltest/') or die $ff->error; } if (-e '/tmp/xbrltest/xbrlrss-2015-09.xml') { print "Download 09 Successful\n"; } else {print "Download 09 Failed\n";} if (-e '/tmp/xbrltest/xbrlrss-2015-10.xml') { print "Download 10 Successful\n"; } else {print "Download 10 Failed\n";} if (-e '/tmp/xbrltest/xbrlrss-2015-11.xml') { print "Download 11 Successful\n"; } else {print "Download 11 Failed\n";} print "Done!\n"