commit 102c80fe9a0c26359722680f7f32dd5f6f250135
parent 435b47c482f7bc5bd9674c296a844f7c0c7a60a8
Author: Kyle Milz <kyle@getaddrinfo.net>
Date: Fri, 24 Oct 2014 01:28:23 -0600
remove redundant scalar calls
Diffstat:
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/gen_svg.pl b/gen_svg.pl
@@ -27,7 +27,7 @@ if ($args{p}) {
}
else {
gen_chart($_) for (@$products);
- print $log scalar(@$products) . " products generated\n";
+ print $log @$products . " products generated\n";
}
sub gen_chart
@@ -54,19 +54,21 @@ sub gen_chart
$query = "select distinct vendor from prices where part_num = ?";
my $vendors = $dbh->selectcol_arrayref($query, undef, $part_num);
- vprintf("\tvendors: " . scalar @$vendors . "\n");
+ vprintf("\tvendors: " . @$vendors . "\n");
for (@$vendors) {
+ vprintf("\t$_:\n");
+
$query = "select date from prices where " .
"part_num = ? and vendor = ? order by date";
my $dates = $dbh->selectcol_arrayref($query, undef,
$part_num, $_);
- vprintf("\tdates found: " . scalar @$dates . "\n");
+ vprintf("\t\tdates found: " . @$dates . "\n");
$query = "select price from prices where " .
"part_num = ? and vendor = ? order by date";
my $prices = $dbh->selectcol_arrayref($query, undef,
$part_num, $_);
- vprintf("\tprices found: " . scalar @$prices . "\n");
+ vprintf("\t\tprices found: " . @$prices . "\n");
my @xs = map { ($_ - $x_min) / ($x_max - $x_min) * 900 + 30 } @$dates;
my @ys = map { ($_ - $y_min) / ($y_max - $y_min) * 210 + 20 } @$prices;
diff --git a/price_scraper.pl b/price_scraper.pl
@@ -22,7 +22,7 @@ else {
my $cutoff = time - (30 * 24 * 60 * 60);
my $results = $dbh->selectcol_arrayref("select part_num from products " .
"where last_seen > $cutoff order by last_scraped asc");
- if (scalar $results == 0) {
+ if (! @$results) {
print "Product table empty, run product_scraper.pl\n";
exit;
}
@@ -69,7 +69,7 @@ for (sort keys $cfg->{vendors}) {
my @prices = ($price =~ m/(\d[\d,]+)/);
if (@prices != 1) {
- msg("r", "error: too many regex matches: " . scalar @prices);
+ msg("r", "error: too many regex matches: " . @prices);
next;
}
@@ -105,7 +105,7 @@ sub get_price
my $dom = shift;
my @prices = $dom->find($dom_element)->text_array();
- vprintf("\t%s = %i\n", $dom_element, scalar @prices);
+ vprintf("\t%s = %i\n", $dom_element, @prices);
return $prices[0];
}
diff --git a/product_scraper.pl b/product_scraper.pl
@@ -72,7 +72,7 @@ for (keys %product_map) {
push @results, $dom->find(".PIV_Regular")->html_array();
}
- vprint("$_: found " . scalar @results . " products\n");
+ vprint("$_: found " . @results . " products\n");
my $new = 0;
my $old = 0;
@@ -130,7 +130,7 @@ for (keys %product_map) {
}
$email .= sprintf("%7s %5s %3s %4s\n",
- $new + $old, scalar @results, $new, time - $start);
+ $new + $old, @results, $new, time - $start);
}
$email .= "\nNew products:\n" if (@new);