ok, here is the code I put together from the really helpful response. it runs with no errors, it just doesn't download...
I must be missing something.
$host = "localhost";
$port = "3306";
$dbdriver='mysql';
$tablename = "linktable";
print "Enter year and month to download in format YYYYMM:";
$date = <STDIN>;
chomp $date;
$dsn = "dbi:$dbdriver:$database:$host:$port";
$path='/data/';
my $dbh = DBI->connect($dsn, $user, $password)
or die "Couldn't connect to database: " . DBI->errstr;
$dbh-> do("DROP TABLE IF EXISTS LINKTABLE");
$dbh-> do("CREATE TABLE IF NOT EXISTS LINKTABLE(document_id CHAR(9),IN
+DEX(DOCUMENT_ID),PUBLISH_DATE CHAR(8),URL CHAR(150))");
$dbh-> do("LOAD DATA LOCAL INFILE '/data/DATA.CSV' INTO TABLE $tablena
+me(DOCUMENT_ID,PUBLISH_DATE)");
$dbh-> do("UPDATE LINKTABLE SET URL=CONCAT('www.example.com/document/'
+,DOCUMENT_ID,'document.pdf')") ;
my $SQL = "select url,document_id FROM $tablename where left(publish_d
+ate,6) ='$date'";
my $query = $dbh->prepare($SQL) or die "prepare: ".$dbh->errstr;
$query-> execute() or die "execute: ".$dbh->errstr;
while ($url,$document_id = $query->fetchrow_array()) {
print "url: $row->{url} \n";
my $outfile = '$path.$document_id';
my $ff = File::Fetch->new( uri => url );
$ff->fetch(to => $outfile) or die "failed to fetch '$url' to '$outf
+ile'.";
#rename("document.pdf","/output/$document_id.pdf") || die "Can't re
+name file: ";