commit 9b86d9acae9879bb70f34931cdc2f4a3cd20883f
parent 7880b232a06efc76b3de8676a555944e0de87f06
Author: Kyle R W Milz <kyle@getaddrinfo.net>
Date: Mon, 11 Aug 2014 23:20:35 -0600
price_scraper: use selectcol_arrayref instead of prepare, execute
Diffstat:
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/price_scraper.pl b/price_scraper.pl
@@ -104,15 +104,13 @@ sub scrape_vendors
my $time_start = time;
my @prices;
- my $sth = $dbh->prepare("select part_num from products");
- $sth->execute();
- my @results = $sth->fetchrow_array();
+ my $results = $dbh->selectcol_arrayref("select part_num from products");
# sequentially pick one product every hour
- my $index = (time / 3600) % scalar(@results);
- my $part_no = $results[$index];
+ my $index = (time / 3600) % scalar(@$results);
+ my $part_no = $results->[$index];
- print strftime '%b %e %Y %H:%M ', localtime;
- printf '%-10s [', $part_no;
+ print strftime "%b %e %Y %H:%M ", localtime;
+ printf "%-15s [", $part_no;
my $ua = LWP::UserAgent->new(agent => 'Mozilla/5.0');
# some sites need this (amazon I think?)