diff options
author | Daniel Friesel <derf@finalrewind.org> | 2010-12-23 23:51:48 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2010-12-23 23:51:48 +0100 |
commit | d41e61a05e27497cccf765c8e23a6eabdcef4afc (patch) | |
tree | 87003f13529e7e714059aee16f026205710a1465 | |
parent | a8ea6a24032e3865eeb701d73bc77f4f06604ef3 (diff) |
hash_in_db: Use keys, not each. Shot myself in the foot without noticing.
-rwxr-xr-x | bin/hashl | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -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; } } |