#!c:\perl\bin\perl # Name: Natalie Hawkins # Email: nhawkins_seattle@yahoo.com # This program is solely my own work, which has been influenced by the various # templates provided, the assignment requirements, and code written in class. use strict; use DBI; use News::ChannelList; use News::Channel; my $file = "channels.txt"; my $channels = require $file; my $db = "DBI:mysql:perlclass"; my $user = "mysqluser"; my $pass = "mysqluser"; my $dbh = DBI->connect($db, $user, $pass, { RaiseError => 1, AutoCommit => 1 }); $dbh->do("delete from channels;"); # load each of the channels into the database foreach my $channel ( @{ $channels } ) { my $ch_obj = News::Channel->new(%$channel); my $title = $ch_obj->getTitle; my $url = $ch_obj->getURL; $dbh->do("insert into channels (title, url) values (" . $dbh->quote($title) . ", " . $dbh->quote($url) . ")"); }