commit dbf95147b16951b3d5cc16f57f49adcafc1dc636
parent 701631b9e70f36bfbeeddc3f5223b02f60dd24af
Author: Kyle R W Milz <kyle@getaddrinfo.net>
Date: Wed, 13 Aug 2014 00:26:50 -0600
price_scraper: hold prices in hash instead of array
Diffstat:
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/price_scraper.pl b/price_scraper.pl
@@ -60,7 +60,7 @@ else {
}
my $time_start = time;
-my @prices;
+my %prices;
my $part_no;
if ($args{p}) {
@@ -113,19 +113,12 @@ while (my ($name, $vendor) = each ($cfg->{vendors})) {
$price =~ s/,//;
print substr($name, 0, 1);
- push @prices, "$name=$price";
+ $prices{$name} = $price;
}
print '] (' . (time - $time_start) . " s)\n";
if ($args{v}) {
- print "$_\n" for @prices;
+ print "$_: $prices{$_}\n" for (keys %prices);
}
-exit if ($args{n} || (scalar @prices) == 0);
-
-mkdir $cfg->{paths}{data};
-open FILE, ">>", "$cfg->{paths}{data}/$part_no.txt" or die $!;
-print FILE time * 1000;
-print FILE "\t$_" for @prices;
-print FILE "\n";
-close FILE;
+exit if ($args{n} || (scalar(keys %prices)) == 0);