#!/usr/bin/perl #INCLUDE LIBRARIES AND MODULES AS NEEDED #use strict; use CGI::Carp qw(fatalsToBrowser); use CGI; use DBI; #assign values $DBuser = "not"; $DBpass = "telling"; $DBtable= "the"; $DBhost = "world"; #connect to Database $dbh = DBI->connect("DBI:mysql:$DBtable:$DBhost", "$DBuser", "$DBpass", { PrintError => 0, RaiseError => 1 } ) || die "Error connecting: $DBI::errstr!"; print "Content-type: text/html\n\n"; #grab files into @files opendir(DIR,"/home/kyleyankan/public_html/content/") || die "Can' open dir: $!"; @files = readdir(DIR); close(DIR); #@files = glob("../public_html/content/*.inc"); #run loop, to transfer each file while (@files) { #print filename print $_ . "\n"; #grab file contents open(FILE,"/home/kyleyankan/public_html/content/$_"); @content = ; close(FILE); while (@content) { $stuff .= $_; } #remove .inc from file $_ =~ s/.inc//; #dump into DB $sth = $dbh->prepare(qq~ INSERT INTO quadrants (title, author, content) VALUES ("$_","KyleYankan","$stuff")~) || die "Can't insert values: $!"; $sth->execute || die "Can't insert values: $!"; } #leave that mysql alone $dbh->disconnect();