summaryrefslogtreecommitdiff
path: root/bin/hashl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2010-12-23 23:51:48 +0100
committerDaniel Friesel <derf@finalrewind.org>2010-12-23 23:51:48 +0100
commitd41e61a05e27497cccf765c8e23a6eabdcef4afc (patch)
tree87003f13529e7e714059aee16f026205710a1465 /bin/hashl
parenta8ea6a24032e3865eeb701d73bc77f4f06604ef3 (diff)
hash_in_db: Use keys, not each. Shot myself in the foot without noticing.
Diffstat (limited to 'bin/hashl')
-rwxr-xr-xbin/hashl12
1 files changed, 7 insertions, 5 deletions
diff --git a/bin/hashl b/bin/hashl
index 52bc5a1..4a7ea92 100755
--- a/bin/hashl
+++ b/bin/hashl
@@ -90,7 +90,9 @@ sub hash_file {
sub hash_in_db {
my ($hash) = @_;
- while (my ($name, $file) = each(%{$db->{'files'}})) {
+ for my $name (keys %{$db->{'files'}}) {
+ my $file = $db->{'files'}->{$name};
+
if ($file->{'hash'} eq $hash) {
return $name;
}
@@ -117,10 +119,10 @@ sub db_find {
while (my $line = <STDIN>) {
chomp $line;
if (
- ($action eq 'know-file' and file_in_db($line)) or
- ($action eq 'know-hash' and hash_in_db($line)) or
- ($action eq 'new-file' and not file_in_db($line)) or
- ($action eq 'new-hash' and not hash_in_db($line))) {
+ ($action eq 'know-file' and defined file_in_db($line)) or
+ ($action eq 'know-hash' and defined hash_in_db($line)) or
+ ($action eq 'new-file' and not defined file_in_db($line)) or
+ ($action eq 'new-hash' and not defined hash_in_db($line))) {
say $line;
}
}